import React, { Component } from "react";
import "./scss/DutyWeek.scss";
import $, { post } from "jquery";
import {
    getData,
    getRealPath,
    getQueryVariable,
    putData1,
    delData,
    postData,
    putData,
} from "../../common/js/fetch";
import {
    LgButton,
    LgSelect,
    LgBlockCard,
    LgBlockCardBox,
    LgDatePicker,
    LgSideBarA,
    LgTabs,
    lgAlert,
    LgPopLayer,
    LgDrawer,
    LgInput,
    LgCheckbox,
    LgTextarea,
    LgSwitch,
    LgEmpty,
    LgRadio,
    LgInputNumber,
} from "lancoo-web-ui";
import "element-theme-default";
import { Scrollbars } from "react-custom-scrollbars";
import LgTable from "./common/table/LgTable";
import RecordTable from "./RecordTable";
import CollectSelectModal from "./common/collectSelectModal";
import moment from "moment";
import Base64 from "../../common/js/fetch/base64";
import SelectUserModal from "lg-select-modal";
import Calendar from "./Calendar";
import UserCalendar from "./UserCalendar";
import ReactEcharts from 'echarts-for-react'
import { message, Menu } from "antd";
import ImportFile from "./ImportFile";
import debounce from 'lodash/debounce';
class DutyWeek extends Component {
    constructor(props) {
        let skin = sessionStorage.getItem('skin');
        super(props);
        this.state = {
            loading: false,
            userInfo: JSON.parse(sessionStorage.getItem("userInfo")),
            termInfo: props.termInfo,
            schoolSystemInfo: JSON.parse(sessionStorage.getItem("schoolSystemInfo")),
            templateList: [],
            templateType: 0,
            setGrouper: true,
            selectedKeys: "",
            weekDetail: null,
            recordId: null,
            recordMgtId: "",
            selectedKeys1: "",
            recordSheetList: [],
            weekSheetDetail: null,
            start: new Date(),
            end: new Date().getTime() + 3600 * 1000 * 24 * 7,
            startDay: new Date(),
            endDay: new Date().getTime() + 3600 * 1000 * 24 * 7,
            cycleList: [],
            selectValue: "",
            weekNo: 1,
            selectUserVisible: false,
            selectUserList: [],
            selectGrouper: "",
            grouperList: [],
            leaderId: null,
            WeekOrDayPlayList: [],
            weekId: "",
            recordTableName: "",
            addWeeksVisible: false,
            AKeyWeekList: [],
            AKeyDayList: [],
            step: 1,
            arrangementOfWay: 1,
            editWeeksVisible: false,
            editWeekIndex: 0,
            selectUserVisibleAKey: false,
            selectGrouperVisibleAKey: false,
            selectUserListAKey: [],
            selectGrouperListAKey: [],
            isEasy: false,
            setScheduleResult: null,
            setResultList: [],
            dutyPersonNum: 1,
            calendarData: {},
            requireList: [],
            selectRecordValue: '',
            selectRecordIndex: 0,
            selectRecordId: '',
            statisticsList: [],
            statisticsValue: '',
            statisticsIndex: 0,
            statisticsId: '',
            statisticsStartDate: new Date(JSON.parse(sessionStorage.getItem("termInfo")).termStartDate),
            statisticsEndDate: new Date(JSON.parse(sessionStorage.getItem("termInfo")).termEndDate),
            isAddContent: false,
            contentValue: '',
            contentArr: [],
            contentNumber: 1,
            remindValue: '',
            remindList: [],
            timeReminder: new Date(2016, 9, 10, 8, 30),
            remindId: '',
            addContentVisible: false,
            addContentValue: '',
            weekSheetDetail1: null,
            isRequire: false,
            takeTurns: false,//轮流
            routine: false,//常规
            explicit: false,//明确
            takeTurnsValue: 1,
            dayTime: new Date(),
            dayId: "",
            weekSheetDetail2: null,
            selectTime: new Date(),
            workload: [],
            situation: [],
            option: {},
            timeoutId: null,
            popLayerEditRecord: false,
            myWeeklyData: [],
            teacherRecordPop: false,
            teacherTimeData: null,
            weekDay: '星期一',
            remindPersonList: [],
            remindPersonId: '',
            bindRecord: null,
            setContentPop: false,
            dayTimeAKey: new Date(),
            arrangementInputName: '',
            editName: false,
            exportStartTime: new Date(JSON.parse(sessionStorage.getItem("termInfo")).termStartDate),
            exportEndTime: new Date(JSON.parse(sessionStorage.getItem("termInfo")).termEndDate),
            importVisible: false,

            indexType: 0,
            datalist: [
                {
                    text: "值周值日管理",
                    selected: true,
                    indexType: 0,
                    icon: <div className={'file-icon file-icon-one ' + `file-icon-${skin}`}></div>
                },
                {
                    text: "记录表管理",
                    selected: false,
                    indexType: 1,
                    icon: <div className={'file-icon file-icon-two ' + `file-icon-${skin}`}></div>
                },
                {
                    text: "记录查询",
                    selected: false,
                    indexType: 2,
                    icon: <div className={'file-icon file-icon-three ' + `file-icon-${skin}`}></div>
                },
                {
                    text: "数据统计",
                    selected: false,
                    indexType: 3,
                    icon: <div className={'file-icon file-icon-four ' + `file-icon-${skin}`}></div>
                },
            ],
            timeRanges: [
                { label: "星期一", value: 1, checked: false },
                { label: "星期二", value: 2, checked: false },
                { label: "星期三", value: 3, checked: false },
                { label: "星期四", value: 4, checked: false },
                { label: "星期五", value: 5, checked: false },
                { label: "星期六", value: 6, checked: false },
                { label: "星期日", value: 7, checked: false },
            ],
            dark: false,
            open: true,
            tabList: [],
            defaultTabIndex: 0,
            dutyArr: [],
            textareaValue: "",
            popLayer01: false,
            popLayer02: false,
            popLayer03: false,
            popLayer04: false,
            popLayer05: false,
            popLayerAKey: false,
            popLayerRecord: false,
            timeVisible: false,
            exportedVisible: false,
            exportedRecordVisible: false,
            statisticsVisible: false,
            radioValue: 0,
            timeList: [
                { label: "本周", value: 1, checked: false },
                { label: "本月", value: 2, checked: false },
                { label: "本学期", value: 3, checked: false },
                { label: "自定义", value: 4, checked: false },
            ],
            isManage: sessionStorage.getItem("isManage"),
            weekList: [{}],
            typingTimeout: 0,
            viewportHeight: 440,
            arrangementIndex: 1,
            contentIndex: 0,
            contentUserList: [[], [], [], [], []],
            departmentList: [],
            departmentValue: '',
            departmentId: '',
            departmentIndex: 0,
            addContentPop: false,
            editContentVisible: false,
            textareaRequireValue: '',
            editContentPop: false,
            editContentIndex: 0,
            departmentSelectId: '',
            workloadDetailPop: false,
            workloadDetailList: [],
            workloadUser: '',
            typeList: [
                {
                    text: "全部",
                    idx: 0,
                    typeOf: '',
                }, {
                    text: "值周",
                    idx: 1,
                    typeOf: '1',
                }, {
                    text: "值日",
                    idx: 2,
                    typeOf: '2',
                },
            ],
            typeSelect: '全部',
            typeSelectIndex: 0,
            typeSelectUser: {},
            isDep: sessionStorage.getItem("isDep"),
            depString: '',
        };
        // 创建一个防抖版本的 getWeekNum 方法
        this.debouncedGetWeekNum = debounce(this.getWeekNum, 500);
        this.scrollbarsRef = React.createRef();
        // 添加窗口大小改变的事件监听器
        window.addEventListener('resize', this.handleWindowResize);
    }

    // 2025-05-21 定制部门端功能
    getDepartment = () => {
        let {
            schoolSystemInfo,
            userInfo,
            isDep,
        } = this.state
        // let officeUrl = schoolSystemInfo?.itemUrl;
        let url = 'api/school/department/getAdministrativeDepartmentTree'
        let params = {
            schoolId: userInfo.schoolId,
            schoolLevel: userInfo.schoolLevel,
        }
        if (isDep == '1') {
            url = 'api/school/department/getManagedDepartmentsByUser'
            params = {
                userId: userInfo.userId,
            }
        }
        getData(url, params)
            .then((data) => {
                return data.json();
            })
            .then((json) => {
                if (json.code == "200") {
                    let data = json.data;
                    data = data.map((item, index) => {
                        return {
                            ...item,  // 使用展开操作符复制原始对象的所有属性
                            text: item.departmentName,  // 添加新的text属性，赋值为recordMgtName
                            idx: index,
                        };
                    });
                    if (isDep == '1' && data.length == 0) {
                        this.alertNoDep();
                        return;
                    }
                    console.log(data.map(item => item.departmentId).join(','), "json.data", data);
                    this.setState({
                        departmentList: data,
                        depString: isDep == '1' ? data.map(item => item.departmentId).join(',') : '',
                    }, () => {
                        if (isDep == '1') {
                            this.getWeekList()
                        }
                    })
                } else {
                    message.error(json.msg, 3);
                }
            });
    }

    // 选择部门
    SelectDepartment = (item) => {
        console.log("选择的item:", item);
        this.setState(
            {
                departmentValue: item.text,
                departmentId: item.departmentId,
                departmentIndex: item.idx,
            },
            () => {
            }
        );
    };

    // 选择值周/值日
    SelectType = (item) => {
        let {
            typeSelectUser
        } = this.state
        console.log("选择的item:", item);
        this.setState(
            {
                typeSelect: item.text,
                typeSelectIndex: item.idx,
            },
            () => {
                this.getWorkloadDetail(typeSelectUser, item?.typeOf)
            }
        );
    };

    // 输入框输入值周内容要求
    handleInputChangeR = (e) => {
        // 更新状态
        this.setState({
            textareaRequireValue: e.currentTarget.value,
        });
    };

    editContent = (item) => {
        this.setState({
            contentValue: item?.content,
            textareaRequireValue: item?.require,
            editContentPop: true,
            editContentIndex: item?.key,
        }, () => {
            this.setState({
                addContentPop: true,
            })
        });
    };
    // 获取工作量统计数据详情
    getWorkloadDetail = (item, typeOf) => {
        let {
            schoolSystemInfo,
            userInfo,
            termInfo,
            weekDetail,
            statisticsId,
            statisticsStartDate,
            statisticsEndDate
        } = this.state
        // if (statisticsId === '') {
        //     // message.warn('暂无记录表!')
        //     return;
        // }
        let url = 'api/dw/v2/statistics/workloadDetail'
        let params = {
            schoolId: userInfo.schoolId,
            semester: termInfo.term,
            userId: item.userId,
            typeOf,
            recordMgtId: statisticsId,
            startDate: moment(statisticsStartDate).format('YYYY-MM-DD HH:mm:ss'), //'yyyy-MM-dd HH:mm:ss'
            endDate: moment(statisticsEndDate).format('YYYY-MM-DD HH:mm:ss'),
        }
        getData(url, params)
            .then((data) => {
                return data.json();
            })
            .then((json) => {
                if (json.code == "200") {
                    let data = json.data;
                    this.setState({
                        workloadDetailPop: true,
                        workloadDetailList: data,
                        workloadUser: item?.userName,
                        typeSelectUser: item,
                        typeSelect: typeOf == '' ? '全部' : typeOf == '1' ? '值周' : '值日',
                        typeSelectIndex: typeOf == '' ? 0 : typeOf == '1' ? 1 : 2,
                    })

                    console.log(item, "json.data", data);

                } else {
                    message.error(json.msg, 3);
                }
            });
    }
    // 用户工作量统计导出
    userWorkloadStaticExport = () => {
        let { weekDetail, userInfo, termInfo, typeSelectUser, typeSelectIndex, statisticsId, statisticsStartDate, statisticsEndDate } = this.state;

        getData("/api/dw/v2/export/userWorkloadStaticExport", {
            schoolId: userInfo.schoolId,
            semester: termInfo.term,
            userId: typeSelectUser.userId,
            typeOf: typeSelectIndex == 0 ? '' : typeSelectIndex == 1 ? '1' : '2',
            recordMgtId: statisticsId,
            startTime: moment(statisticsStartDate).format('YYYY-MM-DD HH:mm:ss'), //'yyyy-MM-dd HH:mm:ss'
            endTime: moment(statisticsEndDate).format('YYYY-MM-DD HH:mm:ss'),
        })
            .then((res) => {
                if (res.ok) {
                    return (res.blob());
                } else {
                    throw new Error('导出失败，请重试！');
                }
            })
            .then((blob) => {
                // 创建下载链接
                let downloadUrl = URL.createObjectURL(blob);

                // 创建 <a> 元素并设置下载链接
                let link = document.createElement('a');
                link.href = downloadUrl;
                let arrangementName = typeSelectUser.userName;
                let fileName = `${arrangementName}值周值日详情.xls`;

                link.download = fileName; // 设置下载文件名

                // 模拟点击下载
                link.click();

                // 释放下载链接资源
                URL.revokeObjectURL(downloadUrl);

                this.setState({
                    downLoading: false
                })
            })
    }

    alertNoDep = () => {
        let alert = lgAlert.show({
            duration: 0,
            content: <span>请先加入部门</span>,
            isShowCloseBtn: false,
            tipType: "error",
            tipSize: "small",
            tipMouldType: "A",
            showConfirm: false,
            // confirmText: "确定",
            closeText: "返回首页",
            showClose: false,
            showCover: true,
            coverZIndex: 1000,
            coverOpacity: 0.25,
            onCancel: () => {
                let edu = getQueryVariable('edu');
                let userType = sessionStorage.getItem('userInfo').userType;
                let userClass = sessionStorage.getItem('userInfo').userClass;
                let token = sessionStorage.getItem('token');
                let baseUrl = sessionStorage.getItem('baseUrl');
                if (edu) {
                    if (userType == 6 && userClass == 2) {
                        window.open(baseUrl + '/Index_A_aspx?lg_tk=' + token, '_blank');
                    }
                } else {
                    window.open(baseUrl + 'office-platform/html/index/index.html?lg_tk=' + token, '_self');
                }
            },
            // onConfirm: () => {
            //     if (type === "delWeek") {
            //         this.deleteWeeklyDayPlay(item);
            //     } else if (type === 'delRecord') {
            //         this.deleteRecordMgt();
            //     } else if (type === 'delContent') {
            //         this.addContent('del', item?.key)
            //     }
            //     lgAlert.close(alert.index);
            // },
        });
    };
    handleWindowResize = () => {
        let { isManage } = this.state
        let viewportHeight = window.innerHeight;
        if (viewportHeight >= 900) {
            viewportHeight = 440
        } else {
            if (isManage == 1) {
                viewportHeight = viewportHeight * 0.43
            } else {
                viewportHeight = viewportHeight * 0.35
            }
        }
        this.setState({
            viewportHeight: viewportHeight
        })
        console.log('窗口高度变化：', viewportHeight);
    }

    // 一个方法来处理滚动到指定位置的逻辑
    scrollToPosition = (index, length) => {
        if (!index) return;
        if (this.scrollbarsRef.current) {
            // 计算目标位置的百分比
            const percentage = (index / length) * 100;
            // 计算滚动条可滚动范围的高度
            const scrollHeight = this.scrollbarsRef.current.getScrollHeight();
            // 计算目标位置的像素值
            const position = (percentage * scrollHeight) / 100;
            // 滚动到目标位置
            this.scrollbarsRef.current.scrollTop(position);
        }
    };

    // 挂载后
    async componentDidMount() {
        // console.log(this.state.termInfo, 'this.state.termInfo');
        let isRecord = getQueryVariable('isRecord');
        let recordMgtId = getQueryVariable('recordMgtId');
        let {
            isManage,
            datalist,
        } = this.state
        if (isManage == 1) {
            if (isRecord == 1) {
                this.getWeekList();
                // 在页面加载完成后，修改状态
                const updatedList = [...datalist]; // 创建副本，避免直接修改 state
                updatedList[0].selected = false; // 将第一项的 selected 状态设为 false
                updatedList[1].selected = true; // 将第二项的 selected 状态设为 true
                this.setState({ datalist: updatedList }, () => {
                    this.selectedItem(updatedList[1]);
                    if (!recordMgtId) {
                        setTimeout(() => {
                            this.openDrawer("addRecordTable")
                        }, 1000);
                    }
                }); // 更新状态
            } else {
                this.selectedItem(datalist[0]);
            }
        } else {
            this.calendarForPersonage()
        }
        this.setState({
            loading: true,
        }, () => {
            this.getDepartment();
        });
    }
    componentWillUnmount() {
        // 组件卸载时清除 timeoutId
        const { timeoutId } = this.state;
        if (timeoutId) {
            clearTimeout(timeoutId);
        }
    }

    // 通过周次获取时间信息
    getWeekNum = () => {
        let { userInfo, weekNo } = this.state;
        getData("/api/common/school/term/week/info", {
            schoolId: userInfo.schoolId,
            weekNo,
        })
            .then((data) => {
                return data.json();
            })
            .then((json) => {
                if (json.code == "200") {
                    let data = json.data;
                    this.setState({
                        start: new Date(data.startDate),
                        end: new Date(data.endDate),
                        dayTime: new Date(data.startDate),
                        dayTimeAKey: new Date(data.startDate),
                        startDay: new Date(data.startDate),
                        endDay: new Date(data.endDate),
                    });

                    console.log("json.data", json.data);
                } else {
                    message.error(json.msg, 3);
                }
            });
    };

    //搜索用户
    searchUser = () => {
        let { userInfo, weekNo } = this.state;
        getData("/api/common/user//noPage/searchUser", {
            schoolId: userInfo.schoolId,
            weekNo,
        })
            .then((data) => {
                return data.json();
            })
            .then((json) => {
                if (json.code == "200") {
                    let data = json.data;

                    console.log("json.data", json.data);
                } else {
                    message.error(json.msg, 3);
                }
            });
    };

    // 提醒相关接口
    // 提醒领导查看记录
    remindRecordLeader = (callback) => {
        let { userInfo, termInfo, selectUserListAKey, remindPersonId } = this.state;
        if (selectUserListAKey.length === 0) {
            message.warn('未选择领导！');
            return;
        }
        let reminderList = selectUserListAKey.map(item => item.userId);
        postData("/api/dw/v2/remind/remindRecord/byLeader", {
            id: remindPersonId,
            reminderList,
            pusherId: userInfo.userId,
            schoolId: userInfo.schoolId,
            semester: termInfo.term,
        })
            .then((data) => {
                return data.json();
            })
            .then((json) => {
                if (json.code == "200") {
                    let data = json.data;
                    message.success('提醒成功~');
                    if (callback) {
                        callback();
                    }
                    this.remindRecordUser();
                    console.log("json.data", json.data);
                } else {
                    message.error(json.msg, 3);
                }
            });
    };

    // 获取提醒查看记录的领导列表
    remindRecordUser = () => {
        let { userInfo, termInfo } = this.state;
        getData("/api/dw/v2/remind/remindRecord/user", {
            schoolId: userInfo.schoolId,
            semester: termInfo.term,
        })
            .then((data) => {
                return data.json();
            })
            .then((json) => {
                if (json.code == "200") {
                    let data = json.data;
                    this.setState({
                        remindPersonId: data?.id || '',
                        remindPersonList: data?.dwV2RemindRecordByUserList || [],
                        selectUserListAKey: data?.dwV2RemindRecordByUserList.concat([]) || [],
                    })

                    console.log("json.data", json.data);
                } else {
                    message.error(json.msg, 3);
                }
            });
    };

    // 提醒今日值周/值日老师值周值日
    remindTeacher = () => {
        let { userInfo, termInfo, weekDetail, departmentSelectId } = this.state;
        if (weekDetail?.weeklyPlayList && weekDetail?.weeklyPlayList.length === 0) {
            message.warn(`还未安排相关${weekDetail.typeOf === '1' ? '值周' : '值日'}人员`)
            return;
        }
        message.loading(`正在提醒相关${weekDetail.typeOf === '1' ? '值周' : '值日'}人员~`)
        getData("/api/dw/v2/remind/remindTeacher", {
            schoolId: userInfo.schoolId,
            semester: termInfo.term,
            type: weekDetail.typeOf,
            pusherId: userInfo.userId,
            arrangementId: weekDetail.arrangementId,
            departmentId: weekDetail?.departmentId || '',
            unloading: true,
        })
            .then((data) => {
                return data.json();
            })
            .then((json) => {
                if (json.code == "200") {
                    let data = json.data;
                    message.success(`已提醒相关${weekDetail.typeOf === '1' ? '值周' : '值日'}人员~`)
                    console.log("json.data", json.data);
                } else {
                    message.error(json.msg, 3);
                }
            });
    };

    // 提醒今日值周/值日老师值周值日
    remindTeacherByPlay = (id) => {
        let { userInfo, termInfo, weekDetail } = this.state;
        console.log(weekDetail, 'weekDetail');
        if (weekDetail?.weeklyPlayList && weekDetail?.weeklyPlayList.length === 0 && weekDetail.typeOf === '1') {
            message.warn(`还未安排相关值周人员`)
            return;
        }
        if (weekDetail?.dayPlayList && weekDetail?.dayPlayList.length === 0 && weekDetail.typeOf === '2') {
            message.warn(`还未安排相关值日人员`)
            return;
        }
        message.loading(`正在提醒相关${weekDetail.typeOf === '1' ? '值周' : '值日'}人员~`)
        getData("/api/dw/v2/remind/remindTeacherByPlay", {
            schoolId: userInfo.schoolId,
            semester: termInfo.term,
            type: weekDetail.typeOf,
            pusherId: userInfo.userId,
            templateId: weekDetail.templateId,
            id,
            unloading: true,
        })
            .then((data) => {
                return data.json();
            })
            .then((json) => {
                if (json.code == "200") {
                    let data = json.data;
                    message.success(`已提醒相关${weekDetail.typeOf === '1' ? '值周' : '值日'}人员~`)
                    console.log("json.data", json.data);
                } else {
                    message.error(json.msg, 3);
                }
            });
    };

    // 获取值周/值日提醒设置
    getRemindList = () => {
        let { userInfo, termInfo, weekDetail, departmentSelectId } = this.state;
        getData("/api/dw/v2/remind/getList", {
            schoolId: userInfo.schoolId,
            semester: termInfo.term,
            type: weekDetail.typeOf,
            arrangementId: weekDetail.arrangementId,
            departmentId: departmentSelectId,
        })
            .then((data) => {
                return data.json();
            })
            .then((json) => {
                if (json.code == "200") {
                    let data = json.data;
                    data.sort((a, b) => {
                        if (a.remindDate < b.remindDate) return -1;
                        if (a.remindDate > b.remindDate) return 1;
                        return 0;
                    });
                    this.setState({
                        remindList: data,
                    })

                    console.log("json.data", json.data);
                } else {
                    message.error(json.msg, 3);
                }
            });
    };

    // 保存值周/值日提醒设置
    remindSave = () => {
        let { userInfo, termInfo, weekDetail, remindValue, timeReminder, timeRanges, remindId, departmentSelectId, } = this.state;
        // 使用filter方法过滤出checked为true的项，并提取value值组成新数组scopeList
        let scopeList = timeRanges.filter(item => item.checked).map(item => item.value);
        postData("/api/dw/v2/remind/save", {
            remindId,
            arrangementId: weekDetail.arrangementId,
            remindItem: remindValue,
            remindDate: moment(timeReminder).format('HH:mm'),
            scopeList,
            typeOf: weekDetail.typeOf,
            schoolId: userInfo.schoolId,
            semester: termInfo.term,
            departmentId: departmentSelectId,
        })
            .then((data) => {
                return data.json();
            })
            .then((json) => {
                if (json.code == "200") {
                    let data = json.data;
                    this.setState({
                        timeVisible: false,
                    }, () => {
                        this.getRemindList();
                        this.clearRemind();
                    })
                    console.log("json.data", json.data);
                } else {
                    message.error(json.msg, 3);
                }
            });
    };

    // 删除值周/值日提醒设置
    delRemindItem = (id) => {
        console.log(id, 'remindList[idx]');
        delData("/api/dw/v2/remind/delete", {
            remindId: id,
        })
            .then((data) => {
                return data.json();
            })
            .then((json) => {
                if (json.code == "200") {
                    message.success("删除成功~");
                    this.getRemindList()
                } else {
                    message.error(json.msg, 3);
                }
            });
    }

    clearRemind = () => {
        this.setState({
            remindId: '',
            remindValue: '',
            timeReminder: new Date(2016, 9, 10, 8, 30),
            timeRanges: [
                { label: "星期一", value: 1, checked: false },
                { label: "星期二", value: 2, checked: false },
                { label: "星期三", value: 3, checked: false },
                { label: "星期四", value: 4, checked: false },
                { label: "星期五", value: 5, checked: false },
                { label: "星期六", value: 6, checked: false },
                { label: "星期日", value: 7, checked: false },
            ],
        })
    }

    // 记录相关接口
    // 管理端、个人端--获取记录详情
    recordInfoDetail = (recordId = null, time) => {
        this.setState({
            recordId,
            selectTime: time ? time : this.state.selectTime,
            isManage,
        }, () => {
            // console.log(time, '12345678', recordId);
            if (recordId === null) {
                // message.warn('所选择日期没有值日记录！')
                return;
            }
            // let { recordId } = this.state;
            getData("/api/dw/v2/recordInfo/detail", {
                recordId,
            })
                .then((data) => {
                    return data.json();
                })
                .then((json) => {
                    if (json.code == "200") {
                        let data = json.data;
                        this.setState({
                            weekSheetDetail2: data,
                        }, () => {
                            if (isManage != 1) {
                                this.remindRecordUser()
                            }
                        })
                        console.log("json.data", json.data);
                    } else {
                        message.error(json.msg, 3);
                    }
                });
        })
    };

    // 管理端--获取记录日历
    calendarForManage = () => {
        let { userInfo, termInfo, requireList, selectRecordId, isRequire } = this.state;
        console.log(requireList, 'requireList', isRequire, 'selectRecordId', selectRecordId);
        if (!isRequire && !selectRecordId) {
            this.getRecordMgtList('require', () => this.calendarForManage(), isRequire)
            return;
        }
        if (selectRecordId === '') {
            // message.warn('暂无相关记录表!');
            return
        }
        getData("/api/dw/v2/recordInfo/calendarForManage", {
            schoolId: userInfo.schoolId,
            semester: termInfo.term,
            recordMgtId: selectRecordId,
            userId: userInfo.userId,
        })
            .then((data) => {
                return data.json();
            })
            .then((json) => {
                if (json.code == "200") {
                    let data = json.data;
                    let arr = data.calendarVoList, month = moment().format('M');
                    let index = arr.findIndex(item => item.month == month), length = arr.length;

                    let toDay = arr.flatMap(monthObj => monthObj.calendarDetaiForManageVoList).find(day => day.beToday === "1");

                    this.setState({
                        calendarData: data,
                    }, () => {
                        this.scrollToPosition(index, length)
                        if (toDay) {
                            this.recordInfoDetail(toDay.recordId)
                        } else {
                            this.getRecordMgtDetail(selectRecordId)
                        }
                    })
                    console.log("json.data1", data);
                } else {
                    message.error(json.msg, 3);
                }
            });
    };

    //个人端--获取记录日历
    calendarForPersonage = () => {
        let { recordMgtId, userInfo, termInfo } = this.state;
        getData("/api/dw/v2/recordInfo/calendarForPersonage", {
            schoolId: userInfo.schoolId,
            semester: termInfo.term,
            userId: userInfo.userId,
        })
            .then((data) => {
                return data.json();
            })
            .then((json) => {
                if (json.code == "200") {
                    let data = json.data;
                    this.setState({
                        calendarData: data,
                    }, () => {
                        let toDay = data.calendarVoList.flatMap(monthObj => monthObj.calendarDetaiForPersonalVoList).find(day => day.beToday === "1");
                        if (toDay) {
                            this.getMyWeeklyDayDetailList(toDay);
                        }
                        this.getWeekList();
                        setTimeout(() => {
                            this.getRecordMgtList();
                        }, 500);
                    })
                    // this.getRecordMgtDetail(selectRecordId)
                    console.log("json.data1", data);
                } else {
                    message.error(json.msg, 3);
                }
            });
    };

    // 记录表管理--保存记录表
    saveRecordMgt = () => {
        let {
            userInfo,
            termInfo,
            recordMgtId,
            recordTableName,
            WeekOrDayPlayList,
            popLayerEditRecord,
            selectedKeys1,
        } = this.state;
        if (recordTableName === "") {
            message.warn("请输入记录表名称！");
            return;
        }
        let arrangementIdList = WeekOrDayPlayList.filter((item) => item.check).map(
            (item) => item.arrangementId
        );
        let departmentId1 = WeekOrDayPlayList.filter((item) => item.check).map(
            (item) => item.departmentId
        );
        if (arrangementIdList.length === 0) {
            message.warn("请选择需要关联的值周/值日安排表!");
            return;
        }

        let obj = {
            recordMgtId: popLayerEditRecord ? selectedKeys1 : recordMgtId,
            recordMgtName: recordTableName,
            arrangementIdList,
            semester: termInfo.term,
            schoolId: userInfo.schoolId,
            departmentId: departmentId1[0],
        };
        postData("/api/dw/v2/recordMgt/save", obj)
            .then((data) => {
                return data.json();
            })
            .then((json) => {
                if (json.code == "200") {
                    message.success("保存记录表成功~");
                    this.setState(
                        {
                            popLayerRecord: false,
                            recordTableName: "",
                        },
                        () => {
                            if (popLayerEditRecord) {
                                this.setState({
                                    popLayerEditRecord: false,
                                }, () => {
                                    this.getRecordMgtDetail()
                                })
                            } else {
                                this.getRecordMgtList();
                            }
                        }
                    );
                } else {
                    message.error(json.msg, 3);
                }
            });
    };

    //记录表管理--查询安排列表
    getWeekOrDayPlayList = (type) => {
        let { userInfo, termInfo, weekSheetDetail } = this.state;
        getData("/api/dw/v2/recordMgt/getWeekOrDayPlayList/forRecord", {
            schoolId: userInfo.schoolId,
            semester: termInfo.term,
            departmentId: isDep == '1' ? depString : '',
        })
            .then((data) => {
                return data.json();
            })
            .then((json) => {
                if (json.code == "200") {
                    let data = json.data;
                    let arrangementIdList = weekSheetDetail?.arrangementIdList || [];
                    data.map((item) => (item.check = false));
                    if (type === 'editRecordTable') {
                        // 遍历 data 数组，为符合条件的对象添加 check=true 属性
                        data.forEach(item => {
                            if (arrangementIdList.includes(item.arrangementId)) {
                                item.check = true;
                                item.canCheck = true;
                            }
                        });
                    }
                    this.setState({
                        WeekOrDayPlayList: data,
                        recordTableName: type === 'editRecordTable' ? weekSheetDetail.recordMgtName : ''
                    });
                    console.log("json.data", json.data);
                } else {
                    message.error(json.msg, 3);
                }
            });
    };

    //记录表管理--查询记录表列表
    getRecordMgtList = (type, callback, isRequire = true) => {
        let recordMgtId = getQueryVariable('recordMgtId');
        let { userInfo, termInfo, popLayer02, selectedKeys, indexType, isDep, depString, } = this.state;
        getData("/api/dw/v2/recordMgt/list", {
            schoolId: userInfo.schoolId,
            semester: termInfo.term,
            departmentId: isDep == '1' ? depString : '',
        })
            .then((data) => {
                return data.json();
            })
            .then((json) => {
                if (json.code == "200") {
                    let data = json.data;
                    // if (type === 'statistics') {
                    data = data.map((item, index) => {
                        return {
                            ...item,  // 使用展开操作符复制原始对象的所有属性
                            text: item.recordMgtName,  // 添加新的text属性，赋值为recordMgtName
                            idx: index,
                        };
                    });
                    let idx = 0;
                    if (recordMgtId) {
                        idx = data.findIndex(item => item.recordMgtId == recordMgtId);
                    }
                    this.setState({
                        statisticsList: data,
                        statisticsValue: data.length > 0 ? data[idx < 0 ? 0 : idx].text : '',
                        statisticsId: data.length > 0 ? data[idx < 0 ? 0 : idx].recordMgtId : '',
                        requireList: data,
                    }, () => {
                        if (!popLayer02 && indexType === 3) {
                            this.getWorkload()
                        } else {
                            let index = -1;
                            for (let i = 0; i < data.length; i++) {
                                const arrangementIds = data[i].arrangementIdList;
                                if (arrangementIds.includes(String(selectedKeys))) {
                                    index = i; // 找到匹配的值，设置索引并立即返回
                                    break;
                                }
                            }
                            if (index !== -1) {
                                this.setState({
                                    bindRecord: data[index]
                                })
                            } else {
                                this.setState({
                                    bindRecord: null
                                })
                            }
                        }
                    })
                    // return
                    // }
                    this.setState(
                        {
                            recordSheetList: data,
                        },
                        () => {
                            // this.getWeekOrDayPlayList();//查询可以关联的表
                            if (type === 'require') {
                                data = data.map((item, index) => {
                                    return {
                                        ...item,  // 使用展开操作符复制原始对象的所有属性
                                        text: item.recordMgtName,  // 添加新的text属性，赋值为recordMgtName
                                        idx: index,
                                    };
                                });
                                this.setState({
                                    requireList: data,
                                    selectRecordValue: data.length > 0 ? data[0].text : '',
                                    selectRecordId: data.length > 0 ? data[0].recordMgtId : '',
                                    isRequire: true,
                                }, () => {
                                    if (callback) {
                                        callback();
                                    }
                                })
                                return
                            }
                            if (type !== 'manage') {
                                if (data.length > 0) {
                                    this.setState(
                                        {
                                            selectedKeys1: data[idx < 0 ? 0 : idx].recordMgtId,
                                        },
                                        () => {
                                            this.getRecordMgtDetail();
                                        }
                                    );
                                }
                            }
                        }
                    );
                } else {
                    message.error(json.msg, 3);
                }
            });
    };

    //记录表管理--查询记录表详情
    getRecordMgtDetail = (id) => {
        let { selectedKeys1, dutyArr, indexType } = this.state;
        getData("/api/dw/v2/recordMgt/detail", {
            recordMgtId: indexType == 2 && id ? id : selectedKeys1,
        })
            .then((data) => {
                return data.json();
            })
            .then((json) => {
                if (json.code == "200") {
                    let data = json.data;
                    const matchedArrangementNames = data?.arrangementIdList.map(id => {
                        const foundArrangement = dutyArr.find(arrangement => arrangement.arrangementId === id);
                        return foundArrangement ? foundArrangement.arrangementName : '';
                    });

                    // 将匹配到的arrangementName数组转换为字符串，用逗号分隔
                    const resultString = matchedArrangementNames.join('、');
                    data.resultString = resultString
                    // console.log(data, 'resultString');
                    if (indexType == 2 && id) {
                        this.setState({
                            weekSheetDetail1: data,
                        });
                    } else {
                        this.setState({
                            weekSheetDetail: data,
                        });
                    }
                } else {
                    message.error(json.msg, 3);
                }
            });
    };

    //记录表管理--删除记录表
    deleteRecordMgt = () => {
        let { selectedKeys1 } = this.state;
        delData("/api/dw/v2/recordMgt/delete", {
            recordMgtId: selectedKeys1,
        })
            .then((data) => {
                return data.json();
            })
            .then((json) => {
                if (json.code == "200") {
                    message.success("删除成功~");
                    let data = json.data;
                    this.getRecordMgtList()
                    console.log("json.data", json.data);
                } else {
                    message.error(json.msg, 3);
                }
            });
    };

    // 保存记录表内容
    saveRecordContent = () => {
        let { selectedKeys1, addContentValue } = this.state;
        if (addContentValue === '') {
            message.warn('请先输入记录事项内容！')
            return
        }
        postData("/api/dw/v2/recordMgt/saveRecordContent", {
            recordMgtId: selectedKeys1,
            recordContent: addContentValue,
        })
            .then((data) => {
                return data.json();
            })
            .then((json) => {
                if (json.code == "200") {
                    message.success("添加成功~");
                    this.setState({
                        addContentVisible: false,
                        addContentValue: '',
                    }, () => {
                        this.getRecordMgtDetail()
                    })
                } else {
                    message.error(json.msg, 3);
                }
            });
    };

    // 值周/值日安排 接口
    // 管理端、个人端--获取值周/值日安排列表
    getWeekList = (needId = true) => {
        let { userInfo, termInfo, isDep, depString } = this.state;
        if (isDep == '1' && depString == '') {
            return;
        }
        getData("/api/dw/v2/weeklyDayPlay/getList", {
            semester: termInfo.term,
            schoolId: userInfo.schoolId,
            departmentId: isDep == '1' ? depString : '',
        })
            .then((data) => {
                return data.json();
            })
            .then((json) => {
                if (json.code == "200") {
                    let data = json.data;
                    this.setState(
                        {
                            dutyArr: data,
                        },
                        () => {
                            if (data.length > 0) {
                                if (needId) {
                                    this.setState(
                                        {
                                            selectedKeys: data[0].arrangementId,
                                            departmentSelectId: data[0]?.departmentId || '',
                                        },
                                        () => {
                                            setTimeout(() => {
                                                this.getWeekDetail();
                                            }, 500);
                                        }
                                    );
                                } else {
                                    this.getWeekDetail();
                                }
                            }
                        }
                    );
                    console.log("json.data", json.data);
                } else {
                    message.error(json.msg, 3);
                }
            });
    };

    // 管理端、个人端--获取值周/值日安排详情
    getWeekDetail = () => {
        let { userInfo, termInfo, isManage, selectedKeys } = this.state;
        getData("/api/dw/v2/weeklyDayPlay/getDetail", {
            semester: termInfo.term,
            schoolId: userInfo.schoolId,
            arrangementId: selectedKeys,
            clientType: isManage,
        })
            .then((data) => {
                return data.json();
            })
            .then((json) => {
                if (json.code == "200") {
                    let data = json.data;
                    let templateId = data.templateId
                    let dayPlayList = (data.dayPlayList && data.dayPlayList) || null
                    let weeklyPlayList = (data.weeklyPlayList && data.weeklyPlayList) || null
                    if (templateId.includes("day_2") || templateId.includes("day_3")) {
                        dayPlayList.sort((a, b) => {
                            if (Number(a.weekNo) < Number(b.weekNo)) return -1;
                            if (Number(a.weekNo) > Number(b.weekNo)) return 1;
                            if (a.dayTime < b.dayTime) return -1;
                            if (a.dayTime > b.dayTime) return 1;
                            return 0;
                        });
                        data.dayPlayList = dayPlayList;
                    } else if (templateId.includes("week_1") || templateId.includes("week_2")) {
                        weeklyPlayList.sort((a, b) => {
                            if (Number(a.weekNo) < Number(b.weekNo)) return -1;
                            if (Number(a.weekNo) > Number(b.weekNo)) return 1;
                            return 0;
                        });
                        data.weeklyPlayList = weeklyPlayList;
                    }

                    this.setState({
                        weekDetail: data,
                        isEasy: templateId.includes("week_1"),
                        takeTurns: templateId.includes("day_1"),
                        routine: templateId.includes("day_2"),
                        explicit: templateId.includes("day_3"),
                        textareaValue: data.responsibility ? data.responsibility : '',
                        contentArr: data?.arrangementContentList ? data?.arrangementContentList : [],
                        arrangementInputName: data?.arrangementName,
                    });
                } else {
                    message.error(json.msg, 3);
                }
            });
    };

    // 保存值周/值日安排
    createWeek = (type, callback, save = false, edit = false) => {
        let {
            userInfo,
            termInfo,
            isManage,
            templateType,
            templateList,
            setGrouper,
            dutyArr,
            textareaValue,
            weekDetail,
            arrangementInputName,
            departmentId,
            isDep,
        } = this.state;
        let obj = {}
        if (!save) {
            let templateId = templateList[templateType].templateId;
            let name = type === "week" ? "值周安排表" : templateType === 0 ? '轮流安排表' : templateType === 1 ? '常规安排表' : "职责安排表";
            let countOfType1 = dutyArr.filter((item) => item.typeOf === "1").length + 1;
            let newName;

            // 使用立即执行函数表达式 (IIFE) 来创建安全的函数作用域
            (function () {
                let i = countOfType1;
                while (dutyArr.some((item) => item.arrangementName === name + i)) {
                    i++;
                }
                newName = name + i;
            })();

            obj = {
                arrangementId: "",
                arrangementName: newName,
                typeOf: type === "week" ? 1 : 2,
                templateId,
                semester: termInfo.term,
                schoolId: userInfo.schoolId,
                beLeader: setGrouper ? 1 : 0,
                departmentId,
            };
        } else {
            obj = {
                arrangementId: weekDetail.arrangementId,
                arrangementName: arrangementInputName,
                typeOf: weekDetail.typeOf,
                templateId: weekDetail.templateId,
                semester: termInfo.term,
                schoolId: userInfo.schoolId,
                beLeader: weekDetail.beLeader,
                responsibility: textareaValue,
                departmentId,//新增
            };
        }
        if (isDep == '1' && departmentId == '' && !edit && !save) {
            message.warn('请选择部门！', 3);
            return;
        }
        console.log(departmentId, 'departmentId');
        postData("/api/dw/v2/weeklyDayPlay/save", obj)
            .then((data) => {
                return data.json();
            })
            .then((json) => {
                if (json.code == "200") {
                    if (callback) {
                        callback();
                    }
                    if (edit) {
                        this.setState({
                            editName: false,
                        })
                    }
                    if (save && !edit) {
                        this.getWeekDetail();
                    } else {
                        this.getWeekList();
                    }
                } else {
                    message.error(json.msg, 3);
                }
            });
    };

    // 保存值周/值日安排内容
    saveWeekContent = (type = '') => {
        let { userInfo, termInfo, weekDetail, contentArr, contentValue, textareaRequireValue, editContentPop, editContentIndex, } = this.state;
        let contentArray = contentArr.concat([]);
        if (type !== 'del') {
            if (contentValue == '') {
                message.warn('请输入内容', 3);
                return;
            }
            let contentObj = {
                content: contentValue,
                require: textareaRequireValue,
            }
            if (editContentPop) {
                contentArray[editContentIndex] = contentObj
            } else {
                contentArray.push(contentObj);
            }
        }

        if (contentArray.length > 5 && !editContentPop) {
            message.warn('最多支持5条内容', 3);
            // this.setState(prevState => ({
            //     contentArr: prevState.contentArr.slice(0, -1)
            // }));
            return;
        }
        let obj = {
            arrangementId: weekDetail.arrangementId,
            templateId: weekDetail.templateId,
            weekOrDayContentList: contentArray,
            semester: termInfo.term,
            schoolId: userInfo.schoolId,
        };
        postData("/api/dw/v2/weeklyDayPlay/content/save", obj)
            .then((data) => {
                return data.json();
            })
            .then((json) => {
                if (json.code == "200") {
                    if (type === 'del') {
                        message.success('内容删除成功~');
                    } else {
                        message.success('内容保存成功~');
                    }
                    this.setState({
                        // setContentPop: false, //2025-05-23注释
                        // contentArr:[],
                        contentValue: '',
                        textareaRequireValue: '',
                        addContentPop: false,
                    }, () => {
                        this.getWeekDetail();
                    })
                } else {
                    // this.setState(prevState => ({
                    //     contentArr: prevState.contentArr.slice(0, -1)
                    // }));
                    message.error(json.msg, 3);
                }
            });
    };

    //管理端--删除值周/值日安排
    deleteWeeklyDayPlay = (item) => {
        let { weekDetail } = this.state;
        console.log(item, "item");
        delData("/api/dw/v2/weeklyDayPlay/delete", {
            arrangementId: item.arrangementId,
            type: item.typeOf,
        })
            .then((data) => {
                return data.json();
            })
            .then((json) => {
                if (json.code == "200") {
                    message.success("删除成功~");
                    let data = json.data;
                    this.getWeekList();
                    console.log("json.data", json.data);
                } else {
                    message.error(json.msg, 3);
                }
            });
    };

    // 获取我的值周/值日安排详情（个人端）
    getMyWeeklyDayDetailList = (item) => {
        let { userInfo, termInfo, timeRanges } = this.state;
        let recordDetailVoList = item?.recordDetailVoList || [], obj = [], dataOne = {};
        if (recordDetailVoList.length === 0) {
            this.setState({
                myWeeklyData: [],
            })
            return;
        }
        console.log(item, 'item', item.date);
        recordDetailVoList.forEach(itm => {
            dataOne = {
                personnelPlayId: itm.personnelPlayId,
                recordId: itm.recordId,
                type: itm.type,
                userId: userInfo.userId,
                dateTime: item.date,
                semester: termInfo.term,
                schoolId: userInfo.schoolId,
            }
            obj.push(dataOne);
        })
        // obj = obj.filter(itm => (itm.recordId !== null && itm.recordId !== ''));

        postData("/api/dw/v2/weeklyDayPlay/getMyWeeklyDayDetailList", obj)
            .then((data) => {
                return data.json();
            })
            .then((json) => {
                if (json.code == "200") {
                    let data = json.data;
                    this.setState({
                        myWeeklyData: data,
                        weekDay: timeRanges[Number(item.weekNo) - 1].label,
                        selectTime: item.date,
                    })
                } else {
                    this.setState({
                        myWeeklyData: [],
                    })
                    message.error(json.msg, 3);
                }
            });
    };

    // 判断新建周次的日期是否与已有周次的日期冲突
    isOverlapping = (range1Start, range1End, range2Start, range2End) => {
        return !(range1End.isBefore(range2Start) || range1Start.isAfter(range2End));
    }

    hasOverlap = (startDate, endDate, dataArray) => {
        return dataArray.some(item => {
            let itemStart = moment(item.weekStartTime);
            let itemEnd = moment(item.weekEndTime);
            return this.isOverlapping(startDate, endDate, itemStart, itemEnd);
        });
    }

    // 值周/值日人员安排接口
    // 保存值周/值日人员安排
    savePersonnel = (type, releaseStatus, item) => {
        let {
            userInfo,
            termInfo,
            weekDetail,
            weekNo,
            start,
            end,
            leaderId,
            selectUserList,
            selectValue,
            selectGrouper,
            weekId,
            takeTurnsValue,
            timeRanges,
            dayTime,
            takeTurns,
            routine,
            explicit,
            contentArr,
            dayId,
            isEasy,
            arrangementIndex,
            contentUserList,
            departmentSelectId,
        } = this.state;
        let perArr = [];
        console.log(arrangementIndex, 'arrangementIndex', contentUserList, 'selectUserList', selectUserList);

        if (arrangementIndex === 1) {
            perArr = selectUserList.map((item) => item.userId);
        } else {
            perArr = contentUserList.flat().map(item => item.userId);
        }

        if (type === "saveWeek") {
            // if (selectValue === "") {
            //     message.warn("请选择周次");
            //     return;
            // }
            if (contentArr.length === 0 && !isEasy) {
                message.warn("请输入值周内容！");
                return;
            }
            if (selectGrouper === "") {
                message.warn("请选择值周队长！");
                return;
            }
            if (perArr.length === 0) {
                message.warn("请选择值周人员！");
                return;
            }
            let weekArr = weekDetail?.weeklyPlayList ? weekDetail?.weeklyPlayList.concat([]) : [];
            if (weekId != '') {
                weekArr = weekArr.filter(item => item.id != weekId);
            }
            let result = this.hasOverlap(moment(start), moment(end), weekArr);
            if (result) {
                message.warn('所选日期与已有日期重叠，请更新！');
                return;
            }
        }
        let dutyGroupName = '人员' + takeTurnsValue + '组'
        let dayList = timeRanges.filter(item => item.checked === true);
        if (type === "saveDay") {
            if (dayList.length === 0 && takeTurns) {
                message.warn("请选择值日日期");
                return;
            }
            if (contentArr.length === 0 && explicit) {
                message.warn("请输入值日内容！");
                return;
            }
            if (perArr.length === 0) {
                message.warn("请选择值日人员！");
                return;
            }
        }
        let dutyDetailList = timeRanges
            .filter(range => range.checked)
            .map(range => range.value);
        console.log(item, 'itemitemitem,');
        // 计算对半分的索引
        let midIndex = dutyDetailList.length > 1 ? Math.ceil(perArr.length / 2) : dutyDetailList.length;

        // 构造最终的值日详情列表
        let dutyDetailObjects = dutyDetailList.map((week, index) => ({
            week,
            dutyPersonIdList: index % 2 === 0 ? perArr.slice(0, midIndex) : perArr.length > 1 ? perArr.slice(midIndex) : perArr.slice(0, midIndex)
        }));
        console.log(perArr, 'perArr', dayList, 'dutyDetailList', dutyDetailList, 'dutyDetailObjects', dutyDetailObjects);
        let weeklyTermList = this.generateArray(contentArr, perArr, 1);
        if (!Array.isArray(weeklyTermList)) {
            return;
        }
        let obj = {
            id: weekId || dayId,
            templateId: weekDetail.templateId,
            arrangementId: weekDetail.arrangementId,
            weekNo,
            weekStartTime: moment(start).format("YYYY-MM-DD 00:00:00"),
            weekEndTime: moment(end).format("YYYY-MM-DD 23:59:59"),
            leaderId,
            personnelIdList: perArr,
            weeklyTermList,
            releaseStatus,
            semester: termInfo.term,
            schoolId: userInfo.schoolId,
            departmentId: departmentSelectId,
        };

        if (type === "publish") {
            obj = {
                id: item.id,
                templateId: item.templateId,
                arrangementId: item.arrangementId,
                weekNo: item.weekNo,
                weekStartTime: item.weekStartTime,
                weekEndTime: item.weekEndTime,
                leaderId: item.leaderId,
                personnelIdList: item.personnelIdList,
                weeklyTermList: item.weeklyTermList,
                releaseStatus: 1,
                semester: termInfo.term,
                schoolId: userInfo.schoolId,
                departmentId: departmentSelectId,
            };
        }
        console.log(weekDetail, "weekDetail", obj);
        if (weekDetail.templateId === "1") {
            delete obj.personnelIdList;
        } else if (weekDetail.templateId === "2") {
            delete obj.weeklyTermList;
        }

        let dutyTermList = this.generateArray(contentArr, perArr, 2);

        // let dutyTermList = contentArr.map(content => ({
        //     content: content,
        //     personIdList: personIdList,
        //     type: 2
        // }));
        let url = "/api/dw/v2/personnelPlay/save/week";
        if (weekDetail.typeOf === '2') {
            // if (type === "days") {
            url = "/api/dw/v2/personnelPlay/save/day";
            delete obj.weekStartTime;
            delete obj.weekEndTime;
            delete obj.leaderId;
            delete obj.weeklyTermList;
            if (takeTurns) {
                delete obj.weekNo;
                delete obj.personnelIdList;
                obj.dutyGroupName = dutyGroupName;
                obj.dutyDetailList = dutyDetailObjects;
            } else if (routine) {
                obj.dayTime = moment(dayTime).format('YYYY-MM-DD 00:00:00');
            } else if (explicit) {
                obj.dutyTermList = dutyTermList;
                obj.dayTime = moment(dayTime).format('YYYY-MM-DD 00:00:00');
            }
            // }
        }
        if (releaseStatus === 1) {
            obj = {
                ...obj,
                ...item,
                releaseStatus: 1,
            }
        }
        // console.log(obj, 'sdfghjkl;');
        postData(url, obj)
            .then((data) => {
                return data.json();
            })
            .then((json) => {
                if (json.code == "200") {
                    message.success(releaseStatus === 1 ? "发布成功~" : "保存成功~");
                    this.setState(
                        {
                            popLayer01: false,
                            weekNo: 1,
                            start: new Date(),
                            end: new Date().getTime() + 3600 * 1000 * 24 * 7,
                            dayTime: new Date(),
                            leaderId: null,
                            selectUserList: [],
                            selectValue: "",
                            selectGrouper: "",
                            weekId: "",
                            dayId: '',
                            arrangementIndex: 1,
                            contentIndex: 0,
                            contentUserList: [[], [], [], [], []],
                        },
                        () => {
                            this.clearRemind();
                            // this.getWeekDetail();
                            if (weekDetail.typeOf === '1') {
                                this.getWeekList(false);
                            } else {
                                this.getWeekDetail();
                            }
                        }
                    );
                } else {
                    message.error(json.msg, 3);
                }
            });
    };

    // 值日职责安排人
    generateArray = (contentArr, userIdArr, type) => {
        let {
            arrangementIndex,
            contentUserList,
        } = this.state
        let dutyTermList = [];
        if (arrangementIndex === 2) {
            for (let i = 0; i < contentArr.length; i++) {
                const content = contentArr[i]?.content;//定制 加了?.content
                let contentUser = contentUserList[i];
                let userIdList = contentUser.map((item) => item.userId);
                console.log(userIdList, 'userIdList', content, 'contentUser', contentUser);

                if (contentUser.length === 0) {
                    message.warn('请为内容安排人员:' + content);
                    return content;
                }
                dutyTermList.push({
                    content: content,
                    personIdList: userIdList,
                    type
                });
            }
        } else {
            if (userIdArr.length >= contentArr.length) {
                // 用户ID数组长度大于或等于内容数组长度，均分用户ID
                const chunkSize = Math.floor(userIdArr.length / contentArr.length);
                let extraItems = userIdArr.length % contentArr.length; // 计算剩余的用户ID

                for (let i = 0; i < contentArr.length; i++) {
                    const content = contentArr[i]?.content;//定制 加了?.content
                    let personIdList = userIdArr.slice(i * chunkSize, (i + 1) * chunkSize);

                    // 如果有剩余的用户ID，每个内容至少一个用户ID
                    if (extraItems > 0) {
                        personIdList.push(userIdArr[userIdArr.length - extraItems]);
                        extraItems--;
                    }

                    dutyTermList.push({
                        content: content,
                        personIdList: personIdList,
                        type
                    });
                }
            } else {
                // 用户ID数组长度小于内容数组长度，循环使用用户ID，并确保所有内容都有至少一个用户ID
                let userIdIndex = 0;

                for (let i = 0; i < contentArr.length; i++) {
                    const content = contentArr[i]?.content;//定制 加了?.content
                    const userId = userIdArr[userIdIndex];
                    userIdIndex = (userIdIndex + 1) % userIdArr.length; // 循环使用用户ID

                    dutyTermList.push({
                        content: content,
                        personIdList: [userId],
                        type: 2
                    });
                }
            }
        }
        console.log(dutyTermList, 'dutyTermList', contentArr, userIdArr, type);

        return dutyTermList;
    };

    // 一键排班---设置人员值班表
    setPersonnelSchedule = () => {
        let { userInfo, termInfo, weekDetail, selectGrouperListAKey, selectUserListAKey, routine,
            dutyPersonNum, arrangementOfWay, AKeyWeekList, step, contentArr, isEasy, contentNumber, AKeyDayList
        } = this.state;
        let safeContentArray = contentArr.map(item => item.content).filter(content => content !== undefined);//定制增加处理

        let scheduleDateWeekBoList = [], scheduleDateDayBoList = [], leaderIdList = [],
            personnelIdList = selectUserListAKey.map((item) => item.userId);

        if (weekDetail.beLeader == '1') {
            leaderIdList = selectGrouperListAKey.map((item) => item.userId);
        }
        if (weekDetail.typeOf == '1') {
            AKeyWeekList.forEach(item => {
                // 构建新的对象，包含 "weekNo", "weekStartTime", "weekEndTime" 属性
                let newItem = {
                    weekNo: item.weekNo,
                    weekStartTime: item.weekStartTime,
                    weekEndTime: item.weekEndTime
                };
                // 将新对象推入 scheduleDateWeekBoList 数组
                scheduleDateWeekBoList.push(newItem);
            });
        } else {
            AKeyDayList.forEach(item => {
                // 构建新的对象，包含 "weekNo", "dayTime" 属性
                let newItem = {
                    weekNo: item.weekNo,
                    dayTime: item.dayTime,
                };
                // 将新对象推入 scheduleDateDayBoList 数组
                scheduleDateDayBoList.push(newItem);
            });
            console.log(scheduleDateDayBoList, 'scheduleDateDayBoList');
        }
        let obj = {
            arrangementId: weekDetail.arrangementId,
            templateId: weekDetail.templateId,
            type: weekDetail.typeOf,
            leaderIdList,
            personnelIdList,
            playNumber: dutyPersonNum,
            playContentNumber: contentNumber,
            playType: arrangementOfWay,
            // contentList: contentArr,
            contentList: safeContentArray,//定制
            scheduleDateDayBoList,
            scheduleDateWeekBoList,
            semester: termInfo.term,
            schoolId: userInfo.schoolId,
        };
        if (isEasy || routine) {
            delete obj.contentList;
        }
        if (weekDetail.typeOf == '1') {
            delete obj.scheduleDateDayBoList;
        } else {
            delete obj.scheduleDateWeekBoList;
        }
        console.log(obj, '12345678', AKeyWeekList);
        postData("/api/dw/v2/oneKeyScheduling/setPersonnelSchedule", obj)
            .then((data) => {
                return data.json();
            })
            .then((json) => {
                if (json.code == "200") {
                    let data = json.data;
                    this.setState({
                        step: step + 1,
                        setScheduleResult: data,
                        setResultList: data.setPersonnelScheduleVo?.weekVoList || data.setPersonnelScheduleVo?.dayVoList
                    })
                    // this.getWeekDetail();
                } else {
                    message.error(json.msg, 3);
                }
            });
    };

    // 一键排班
    oneKeyScheduling = () => {
        let { userInfo, termInfo, weekDetail, setScheduleResult, AKeyWeekList, departmentSelectId, } = this.state;
        let oneKeySchedulingDayBoList = [], oneKeySchedulingWeekBoList = []
        if (weekDetail.typeOf === '1') {
            oneKeySchedulingWeekBoList = setScheduleResult.setPersonnelScheduleVo.weekVoList
        } else {
            oneKeySchedulingDayBoList = setScheduleResult.setPersonnelScheduleVo.dayVoList
        }
        // console.log(AKeyWeekList,'AKeyWeekList');
        // // return;
        // if (weekDetail.typeOf == '1') {
        //     AKeyWeekList.forEach(item => {
        //         // 构建新的对象，包含 "weekNo", "weekStartTime", "weekEndTime" 属性
        //         let newItem = {
        //             weekNo: item.weekNo,
        //             weekStartTime: item.weekStartTime,
        //             weekEndTime: item.weekEndTime
        //         };
        //         // 将新对象推入 scheduleDateWeekBoList 数组
        //         scheduleDateWeekBoList.push(newItem);
        //     });
        // } else {
        //     AKeyWeekList.forEach(item => {
        //         // 构建新的对象，包含 "weekNo", "dayTime" 属性
        //         let newItem = {
        //             weekNo: item.weekNo,
        //             dayTime: item.dayTime,
        //         };
        //         // 将新对象推入 scheduleDateDayBoList 数组
        //         scheduleDateDayBoList.push(newItem);
        //     });
        // }
        let obj = {
            arrangementId: weekDetail.arrangementId,
            templateId: weekDetail.templateId,
            type: weekDetail.typeOf,
            oneKeySchedulingDayBoList,
            oneKeySchedulingWeekBoList,
            semester: termInfo.term,
            schoolId: userInfo.schoolId,
            departmentId: departmentSelectId,
        };
        if (weekDetail.typeOf === '1') {
            delete obj.oneKeySchedulingDayBoList
        } else {
            delete obj.oneKeySchedulingWeekBoList
        }

        postData("/api/dw/v2/personnelPlay/oneKeyScheduling", obj)
            .then((data) => {
                return data.json();
            })
            .then((json) => {
                if (json.code == "200") {
                    message.success('应用成功！');
                    this.getWeekDetail();
                    this.setState({
                        popLayerAKey: false,
                        step: 1,
                        selectGrouperListAKey: [],
                        selectUserListAKey: [],
                        contentNumber: 1,
                        arrangementOfWay: 1,
                        dutyPersonNum: 1,
                        weekNo: 1,
                        selectValue: "",
                    })
                } else {
                    message.error(json.msg, 3);
                }
            });
    };

    // 撤回值周/值日人员安排
    recallPerson = (id) => {
        let { weekDetail } = this.state;
        putData(
            "/api/dw/v2/personnelPlay/recall?id=" + id + "&type=" + weekDetail.typeOf
        )
            .then((data) => {
                return data.json();
            })
            .then((json) => {
                if (json.code == "200") {
                    message.success("撤回成功~");
                    this.getWeekDetail();
                } else {
                    message.error(json.msg, 3);
                }
            });
    };

    // 删除值周/值日人员安排
    deletePerson = (id) => {
        let { weekDetail } = this.state;
        putData(
            "/api/dw/v2/personnelPlay/delete?id=" + id + "&type=" + weekDetail.typeOf
        )
            .then((data) => {
                return data.json();
            })
            .then((json) => {
                if (json.code == "200") {
                    message.success("删除成功~");
                    if (weekDetail.typeOf === '1') {
                        this.getWeekList(false);
                    } else {
                        this.getWeekDetail();
                    }
                } else {
                    message.error(json.msg, 3);
                }
            });
    };

    // 个人端--值周/值日人员安排详情
    getPersonDetail = () => {
        let { userInfo, termInfo, isManage } = this.state;
        getData("/api/dw/v2/personnelPlay/detail", {
            personnelPlayId: "",
            type: "",
            time: "",
        })
            .then((data) => {
                return data.json();
            })
            .then((json) => {
                if (json.code == "200") {
                    let data = json.data;

                    console.log("json.data", json.data);
                } else {
                    message.error(json.msg, 3);
                }
            });
    };
    // 模板接口
    // 获取值周/值日模版列表
    getTemplate = (type) => {
        let { userInfo } = this.state;
        getData("/api/dw/v2/template/list", {
            schoolId: userInfo.schoolId,
            type,
        })
            .then((data) => {
                return data.json();
            })
            .then((json) => {
                if (json.code == "200") {
                    let data = json.data;
                    this.setState({
                        templateList: data,
                    });
                } else {
                    message.error(json.msg, 3);
                }
            });
    };

    // 统计接口
    // 获取工作量统计数据
    getWorkload = () => {
        let { userInfo, termInfo, statisticsId, statisticsStartDate, statisticsEndDate } = this.state;
        if (statisticsId === '') {
            // message.warn('暂无记录表!')
            return;
        }
        getData("/api/dw/v2/statistics/workload", {
            schoolId: userInfo.schoolId,
            semester: termInfo.term,
            recordMgtId: statisticsId,
            startDate: moment(statisticsStartDate).format('YYYY-MM-DD HH:mm:ss'), //'yyyy-MM-dd HH:mm:ss'
            endDate: moment(statisticsEndDate).format('YYYY-MM-DD HH:mm:ss'),
        })
            .then((data) => {
                return data.json();
            })
            .then((json) => {
                if (json.code == "200") {
                    let data = json.data;
                    this.setState({
                        workload: data,
                    }, () => {
                        this.getSituation()
                    })
                } else {
                    message.error(json.msg, 3);
                }
            });
    };

    // 获取情况统计数据
    getSituation = () => {
        let { userInfo, termInfo, statisticsId, statisticsStartDate, statisticsEndDate } = this.state;
        getData("/api/dw/v2/statistics/situation", {
            schoolId: userInfo.schoolId,
            semester: termInfo.term,
            recordMgtId: statisticsId,
            startDate: moment(statisticsStartDate).format('YYYY-MM-DD HH:mm:ss'), //'yyyy-MM-dd HH:mm:ss'
            endDate: moment(statisticsEndDate).format('YYYY-MM-DD HH:mm:ss'),
        })
            .then((data) => {
                return data.json();
            })
            .then((json) => {
                if (json.code == "200") {
                    let data = json.data;
                    let result = data.reduce((acc, item) => {
                        let { content, normalTimes, otherTimes } = item;
                        if (!acc[content]) {
                            acc[content] = {
                                content,
                                normalTimes: Number(normalTimes),
                                otherTimes: Number(otherTimes)
                            };
                        } else {
                            acc[content].normalTimes += Number(normalTimes);
                            acc[content].otherTimes += Number(otherTimes);
                        }
                        return acc;
                    }, {});
                    let uniqueData = Object.values(result);
                    this.setState({
                        situation: uniqueData,
                    }, () => {
                        this.getChartOptions();
                    })
                } else {
                    message.error(json.msg, 3);
                }
            });
    };

    darkChange = () => {
        let { dark } = this.state;
        if (dark !== true) {
            $('.file-icon').addClass("file-icon-dark")
        } else {
            $('.file-icon').removeClass("file-icon-dark")
        }
        this.setState({
            dark: !dark,
        });
    };

    openChange = () => {
        let { open } = this.state;
        this.setState({
            open: !open,
        });
    };
    update = (datalist) => {
        this.setState({
            datalist,
        });
    };

    //左侧导航切换以及增加顶部导航
    selectedItem = async (data) => {
        let { tabList, termInfo } = this.state;

        let obj = {
            key: data.text,
            label: data.text,
            indexType: data.indexType,
            content: "",
        };
        let arr = tabList.concat([]);
        arr.push(obj);

        //数组对象去重
        let result = Object.values(
            arr.reduce((acc, cur) => {
                let key = cur.key;
                if (!acc[key]) {
                    acc[key] = cur;
                }
                return acc;
            }, {})
        );
        //获取下标,制作导航栏选择联动
        let index = result.findIndex((item) => item.key === data.text);
        console.log(data, 'data.text', index);
        this.setState(
            {
                tabList: result,
                defaultTabIndex: index,
                popLayer01: false,
                popLayer02: false,
                popLayer03: false,
                popLayer04: false,
                popLayer05: false,
                popLayer06: false,
                popLayerAKey: false,
                popLayerRecord: false,
                popLayerEditRecord: false,
                indexType: data.indexType,
                arrangementIndex: 1,
                contentIndex: 0,
                contentUserList: [[], [], [], [], []],
                departmentValue: '',
                departmentId: '',
                departmentIndex: 0,
            },
            () => {
                if (data.text === "值周值日管理") {
                    this.getWeekList();
                } else if (data.text === "记录表管理") {
                    this.getRecordMgtList();
                } else if (data.text === "记录查询") {
                    this.calendarForManage();
                } else if (data.text === "数据统计") {
                    this.getRecordMgtList('statistics')
                }
            }
        );
        // console.log(result, "选中的item", data);
    };

    //顶部导航点击事件
    onTabClick = (index) => {
        let { tabList, datalist } = this.state;
        let arr = tabList.concat([]);
        let key = arr[index].key;
        datalist.forEach((item) => {
            if (item.text === key) {
                item.selected = true;
            } else {
                item.selected = false;
            }
        });
        console.log(datalist[index], "index", index);

        this.setState({
            datalist,
            defaultTabIndex: index,
        });
    };
    //顶部导航关闭
    onCloseTab = (index) => {
        let { tabList } = this.state;
        let arr = tabList.concat([]);
        if (arr.length > 1) {
            arr.splice(index, 1);
        }
        this.setState(
            {
                tabList: arr,
            },
            () => this.onTabClick(arr.length - 1)
        );
    };
    // 取消相应Drawer窗口
    cancelDrawer = () => {
        let {
            popLayer01,
            popLayer02,
            popLayer03,
            popLayer04,
            popLayer05,
            popLayerAKey,
            popLayerRecord,
            popLayerEditRecord,
            setContentPop,
            workloadDetailPop,
        } = this.state;
        if (popLayer01) {
            this.setState({
                popLayer01: false,
                weekNo: 1,
                start: new Date(),
                end: new Date().getTime() + 3600 * 1000 * 24 * 7,
                dayTime: new Date(),
                leaderId: null,
                selectUserList: [],
                selectValue: "",
                selectGrouper: "",
                weekId: "",
                arrangementIndex: 1,
                contentIndex: 0,
                contentUserList: [[], [], [], [], []],
            });
        } else if (popLayer02) {
            this.setState({
                popLayer02: false,
            });
        } else if (popLayer03) {
            this.setState({
                popLayer03: false,
            });
        } else if (popLayer04) {
            this.setState({
                popLayer04: false,
                templateType: 0,
                departmentValue: '',
                departmentId: '',
                departmentIndex: 0,
            });
        } else if (popLayer05) {
            this.setState({
                popLayer05: false,
                templateType: 0,
                departmentValue: '',
                departmentId: '',
                departmentIndex: 0,
            });
        } else if (popLayerAKey) {
            this.setState({
                popLayerAKey: false,
                step: 1,
            });
        } else if (popLayerRecord) {
            this.setState({
                popLayerRecord: false,
            });
        } else if (popLayerEditRecord) {
            this.setState({
                popLayerEditRecord: false,
            });
        } else if (setContentPop) {
            this.setState({
                setContentPop: false,
                contentArr: [],
            });
        } else if (workloadDetailPop) {
            this.setState({
                workloadDetailPop: false,
            });
        }
    };
    // 确认保存
    confirmDrawer = () => {
        let {
            popLayer01,
            popLayer02,
            popLayer03,
            popLayer04,
            popLayer05,
            popLayerAKey,
            popLayerRecord,
            popLayerEditRecord,
            setContentPop,
            workloadDetailPop,
        } = this.state;
        if (popLayer01) {
            this.savePersonnel();
        } else if (popLayer02) {
            this.setState({
                popLayer02: false,
            });
        } else if (popLayer03) {
            this.setState({
                popLayer03: false,
            });
        } else if (popLayer04) {
            this.createWeek("week", () =>
                this.setState({
                    popLayer04: false,
                    templateType: 0,
                    departmentValue: '',
                    departmentId: '',
                    departmentIndex: 0,
                })
            );
        } else if (popLayer05) {
            this.createWeek("day", () =>
                this.setState({
                    popLayer05: false,
                    templateType: 0,
                    departmentValue: '',
                    departmentId: '',
                    departmentIndex: 0,
                })
            );
        } else if (popLayerAKey) {
            this.setState({
                popLayerAKey: false,
            });
        } else if (popLayerRecord || popLayerEditRecord) {
            this.saveRecordMgt();
        } else if (setContentPop) {
            // this.saveWeekContent() //2025-5-23注释并替换为下方方法
            this.cancelDrawer()
        } else if (workloadDetailPop) {
            this.setState({
                workloadDetailPop: false,
            });
        }
    };
    // 打开Drawer弹窗
    openDrawer = (type, item) => {
        console.log(type, item, 'type, itemtype, item');

        let { termInfo, weekDetail, timeRanges, isEasy, requireList, selectRecordIndex, contentUserList } = this.state;
        // 打开添加周次弹窗
        if (type === "addWeek") {
            let datalistA = [];
            for (let i = 1; i <= termInfo.totalWeeks; i++) {
                datalistA.push({
                    text: `第${i}周`,
                    weekNo: `${i}`,
                });
            }
            this.setState({
                popLayer01: true,
                cycleList: datalistA,
                contentArr: weekDetail?.arrangementContentList ? weekDetail?.arrangementContentList : [],
            }, () => {
                let weeklyPlayList = weekDetail?.weeklyPlayList ? weekDetail?.weeklyPlayList : [];
                if (weeklyPlayList.length > 0) {
                    let lastItem = weeklyPlayList[weeklyPlayList.length - 1];
                    let lastItemWeekNo = Number(lastItem?.weekNo) + 1;
                    this.setState({
                        weekNo: lastItemWeekNo
                    }, () => {
                        this.getWeekNum()
                    })
                }

            });
        } else if (type === 'setContent') {
            this.setState({
                setContentPop: true,
                contentArr: weekDetail?.arrangementContentList ? weekDetail?.arrangementContentList : [],
            })
        } else if (type === "log" || type === "log1") {
            // 打开值周记录表设置
            this.setState({
                popLayer02: true,
            }, () => {
                if (type === "log") {
                    this.getRecordMgtList('manage');
                } else {
                    this.setState({
                        bindRecord: requireList.length > 0 ? requireList[selectRecordIndex] : null
                    })
                }
            });
        } else if (type === "reminder") {
            // 打开提醒设置
            this.setState({
                popLayer03: true,
            }, () => {
                this.getRemindList();
            });
        } else if (type === "addWeekTable") {
            // 打开创建值周安排表
            this.setState(
                {
                    popLayer04: true,
                },
                () => {
                    this.getTemplate(1);
                }
            );
        } else if (type === "addDayTable") {
            // 打开创建值日安排表
            this.setState({
                popLayer05: true,
            }, () => {
                this.getTemplate(2);
            });
        } else if (type === "aKeyScheduling") {
            // 打开一键排班
            this.setState({
                popLayerAKey: true,
                AKeyWeekList: weekDetail?.weeklyPlayList ? weekDetail?.weeklyPlayList.concat([]) : [],
                AKeyDayList: weekDetail?.dayPlayList ? weekDetail?.dayPlayList.concat([]) : [],
            });
        } else if (type === "addRecordTable") {
            // 打开一键排班
            this.setState(
                {
                    popLayerRecord: true,
                },
                () => {
                    this.getWeekOrDayPlayList(); //查询可以关联的表
                }
            );
        } else if (type === "editRecordTable") {
            // 打开一键排班
            this.setState(
                {
                    popLayerEditRecord: true,
                },
                () => {
                    this.getWeekOrDayPlayList('editRecordTable'); //查询可以关联的表
                }
            );
        } else if (type === "editWeek") {
            console.log(item, "45678", isEasy);
            let selectUserList = [];
            // 2025-05-26定制注释
            // let contentArr = [];
            let contentUserList2 = contentUserList.concat([]);
            // // 遍历原始数据数组  
            if (!isEasy) {
                // 遍历原始数据数组  
                item.weeklyTermList && item.weeklyTermList.forEach((item, index) => {
                    // 将personInfoVoList中的每个对象添加到selectUserList数组中  
                    contentUserList2[index] = item.personInfoVoList
                    // selectUserList = [...selectUserList, ...item.personInfoVoList];
                    // 将content添加到contentArr数组中  
                    // contentArr.push(item.content);
                });
            }
            // 2025-05-26定制注释

            // console.log(selectUserList, "selectUserList",item.weeklyTermList[0],'item',item);
            // return;
            let personList = item?.weeklyTermList[0]?.personInfoVoList || []
            selectUserList = [...selectUserList, ...personList];
            let datalistA = [];
            for (let i = 1; i <= termInfo.totalWeeks; i++) {
                datalistA.push({
                    text: `第${i}周`,
                    weekNo: `${i}`,
                });
            }
            this.setState({
                popLayer01: true,
                weekNo: item.weekNo,
                start: new Date(item.weekStartTime),
                end: new Date(item.weekEndTime),
                leaderId: item.leaderId,
                selectUserList: !isEasy ? selectUserList : item.personnelList,
                selectValue: "第" + item.weekNo + "周",
                selectGrouper: item.leader.userName,
                weekId: item.id,
                // contentArr,
                cycleList: datalistA,
                arrangementIndex: isEasy ? 1 : 2,
                contentUserList: contentUserList2,
            });
        } else if (type === 'takeTurnsEdit') {
            let regex = /\d+/; // 匹配一个或多个数字的正则表达式
            let match = item.dutyGroupName.match(regex); // 使用match方法查找匹配项
            let number = 1; // 将字符串转换为整数

            if (match) {
                let numberString = match[0]; // 获取匹配到的第一个字符串（即数字部分）
                number = parseInt(numberString, 10); // 将字符串转换为整数
                console.log(number); // 输出：1
            } else {
                console.log("未找到数字");
            }
            // 使用 reduce 和 Map 来合并所有的 dutyPersonList，并去除重复项  
            let dutyPersonMap = item.dutyDetailList.reduce((acc, curr) => {
                curr.dutyPersonList.forEach(person => {
                    // 使用 userId 作为键来确保唯一性  
                    acc.set(person.userId, person);
                });
                return acc;
            }, new Map());

            // 从 Map 中提取值，创建一个去重后的数组  
            let selectUserList = Array.from(dutyPersonMap.values());

            // 遍历dutyWeeks数组，查找匹配的week值，并更新timeRanges中对应项的checked属性  
            item.dutyDetailList.forEach(weekObj => {
                const weekNum = parseInt(weekObj.week, 10); // 将week字符串转换为整数  
                timeRanges.forEach(timeRange => {
                    if (timeRange.value === weekNum) {
                        timeRange.checked = true;
                    }
                });
            });

            this.setState({
                takeTurnsValue: number,
                selectUserList,
                dayId: item.id,
                timeRanges,
                popLayer01: true,
            });
        } else if (type === 'routineEdit') {
            this.setState({
                weekNo: item.weekNo,
                selectUserList: item.personnelList,
                dayTime: new Date(item.dayTime),
                selectValue: item.weekNo,
                dayId: item.id,
            }, () => {
                this.openDrawer("addWeek")
            });
        } else if (type === 'explicitEdit') {
            // 初始化两个新数组来存储整理后的数据  
            let selectUserList = [];
            let contentArr = [];
            let contentUserList1 = contentUserList.concat([]);
            // 遍历原始数据数组  
            item.dutyTermList.forEach((item, index) => {
                // 将personInfoVoList中的每个对象添加到selectUserList数组中  
                // selectUserList = [...selectUserList, ...item.personInfoVoList];
                contentUserList1[index] = item.personInfoVoList
                // 将content添加到contentArr数组中  
                contentArr.push(item.content);
            });
            selectUserList = [...selectUserList, ...item.dutyTermList[0]?.personInfoVoList];
            this.setState({
                popLayer01: true,
                weekNo: item.weekNo,
                selectUserList,
                contentArr,
                dayTime: new Date(item.dayTime),
                selectValue: item.weekNo,
                dayId: item.id,
                arrangementIndex: 2,
                contentUserList: contentUserList1,
            }, () => {
                this.openDrawer("addWeek")
            });
        }
    };
    // 打开LgPopLayer弹窗
    openPop = (type, item, idx) => {
        let { cycleList, termInfo, weekDetail, timeRanges, AKeyWeekList } = this.state;
        let datalistA = [];
        if (cycleList.length === 0) {
            for (let i = 1; i <= termInfo.totalWeeks; i++) {
                datalistA.push({
                    text: `第${i}周`,
                    weekNo: `${i}`,
                });
            }
            this.setState({
                cycleList: datalistA,
            });
        }
        console.log(cycleList, 'cycleList', datalistA);
        // 打开提醒设置窗口
        if (type === "addReminderTime") {
            this.setState({
                timeVisible: true,
            });
        } else if (type === "exported") {
            // 打开导出数据统计窗口
            this.setState({
                exportedVisible: true,
            });
        } else if (type === "exportedRecord") {
            // 打开导出数据统计窗口
            this.setState({
                exportedRecordVisible: true,
            });
        } else if (type === "addWeeks") {
            // 打开添加周次窗口
            this.setState({
                addWeeksVisible: true,
                contentArr: weekDetail?.arrangementContentList ? weekDetail?.arrangementContentList : [],
            }, () => {
                let weeklyList = AKeyWeekList.concat([]);
                weeklyList.sort((a, b) => {
                    if (Number(a.weekNo) < Number(b.weekNo)) return -1;
                    if (Number(a.weekNo) > Number(b.weekNo)) return 1;
                    return 0;
                });
                if (weeklyList.length > 0) {
                    let lastItem = weeklyList[weeklyList.length - 1];
                    let lastItemWeekNo = Number(lastItem?.weekNo) + 1;
                    this.setState({
                        weekNo: lastItemWeekNo
                    }, () => {
                        this.getWeekNum()
                    })
                }
            });
        }
        else if (type === "editWeeks") {
            // console.log(item, '45t6y7u8i9op');
            // 打开添加周次窗口
            this.setState({
                selectValue: cycleList[Number(item.weekNo) - 1]?.text || datalistA[Number(item.weekNo) - 1]?.text,
                weekNo: item.weekNo,
                start: new Date(item.weekStartTime),
                end: new Date(item.weekStartTime).getTime() + 3600 * 1000 * 24 * 7,
                addWeeksVisible: true,
                editWeeksVisible: true,
                editWeekIndex: idx,
            });
        } else if (type === 'editRemindItem') {
            let inputArray = item.scopeList;
            const updatedTimeRanges = timeRanges.map(item => ({
                ...item,
                checked: inputArray.includes(String(item.value)) // 判断value是否在inputArray中
            }));
            // console.log(item, '45t6y7u8i9op',new Date(moment().format(`YYYY-MM-DD ${item.remindDate}:00`)),'updatedTimeRanges',updatedTimeRanges);
            this.setState({
                timeVisible: true,
                remindId: item.remindId,
                timeRanges: updatedTimeRanges,
                remindValue: item.remindItem,
                timeReminder: new Date(moment().format(`YYYY-MM-DD ${item.remindDate}:ss`)),
            });
        } else if (type === 'teacherRecord') {
            this.setState({
                teacherTimeData: item,
            }, () => {
                this.setState({
                    teacherRecordPop: true,
                }, () => {
                    this.recordInfoDetail(item.recordId)
                })
            })
        } else if (type === 'addContent1') {
            this.setState({
                addContentPop: true,
            })
        }
    };

    // 关闭LgPopLayer弹窗
    cancelObjModal = () => {
        let {
            timeVisible,
            addContentVisible,
            teacherRecordPop,
            addContentPop,
        } = this.state
        if (timeVisible) {
            this.setState({
                timeVisible: false,
            }, () => {
                this.clearRemind();
            })
        } else if (addContentVisible) {
            this.setState({
                addContentVisible: false,
                addContentValue: '',
            })
        } else if (teacherRecordPop) {
            this.setState({
                teacherRecordPop: false,
            })
        } else if (addContentPop) {
            this.setState({
                addContentPop: false,
                contentValue: '',
                textareaRequireValue: '',
            })
        }

        this.setState({
            exportedVisible: false,
            exportedRecordVisible: false,
            addWeeksVisible: false,
            editWeeksVisible: false,
        });
    };

    // 保存LgPopLayer弹窗内容
    okSelected = () => {
        let {
            timeVisible,
            exportedVisible,
            exportedRecordVisible,
            addWeeksVisible,
            AKeyWeekList,
            weekNo,
            start,
            end,
            editWeeksVisible,
            editWeekIndex,
            addContentVisible,
            weekDetail,
            explicit,
            routine,
            AKeyDayList,
            dayTimeAKey,
            selectValue,
            startDay,
            endDay,
            addContentPop,
        } = this.state
        let obj = {}
        if (addWeeksVisible) {
            // if (selectValue === '') {
            //     message.warn('请先选择周次！');
            //     return;
            // }
            if (weekDetail.typeOf === '1') {
                if (AKeyWeekList.find(item => item.weekNo == weekNo)) {
                    message.warn('已有该周次，请重新设置！');
                    return;
                }
                obj = {
                    weekNo,
                    weekStartTime: moment(start).format("YYYY-MM-DD 00:00:00"),
                    weekEndTime: moment(end).format("YYYY-MM-DD 23:59:59"),
                }
                let result = this.hasOverlap(moment(start), moment(end), AKeyWeekList);
                if (result) {
                    message.warn('所选日期与已有日期重叠，请更新！');
                    return;
                }
                if (editWeeksVisible) {
                    AKeyWeekList[editWeekIndex] = {
                        ...AKeyWeekList[editWeekIndex],
                        ...obj,
                    }
                    // console.log(AKeyWeekList, 'AKeyWeekList', editWeekIndex, 'weekNo', weekNo);
                } else {
                    AKeyWeekList.push(obj)
                }
                this.setState({
                    weekNo: 1,
                    start: new Date(),
                    end: new Date().getTime() + 3600 * 1000 * 24 * 7,
                    selectValue: "",
                    AKeyWeekList,
                    addWeeksVisible: false,
                    editWeeksVisible: false,
                })
                // console.log(AKeyWeekList, 'AKeyWeekList');
            } else {
                // 每次只能选择一次2024-08-27
                // if (AKeyDayList.find(item => moment(item.dayTime).format('YYYY-MM-DD') === moment(dayTimeAKey).format('YYYY-MM-DD'))) {
                //     message.warn('已有该日期，请重新选择！');
                //     return;
                // }
                // obj = {
                //     weekNo: explicit ? null : weekNo,
                //     dayTime: moment(dayTimeAKey).format("YYYY-MM-DD 00:00:00"),
                // }
                // if (editWeeksVisible) {
                //     AKeyDayList[editWeekIndex] = {
                //         ...AKeyDayList[editWeekIndex],
                //         ...obj,
                //     }
                //     // console.log(AKeyWeekList, 'AKeyWeekList', editWeekIndex, 'weekNo', weekNo);
                // } else {
                //     AKeyDayList.push(obj)
                // }
                // 批量添加日期遍历日期范围并添加新对象2024-08-27
                let existingDates = new Set(AKeyDayList.map(item => item.dayTime));
                let currentDay = moment(startDay).clone();
                let dayArr = AKeyDayList.concat([]);
                while (currentDay.isSameOrBefore(moment(endDay))) {
                    let dayTime = currentDay.format("YYYY-MM-DD 00:00:00");

                    // 检查日期是否已经存在
                    if (!existingDates.has(dayTime)) {

                        // 创建新对象
                        const newObj = {
                            weekNo: explicit ? null : weekNo,
                            dayTime: dayTime
                        };

                        // 将新对象添加到数组中
                        dayArr.push(newObj);

                        // 更新现有日期集合
                        existingDates.add(dayTime);
                    }

                    // 移动到下一天
                    currentDay.add(1, 'days');
                }
                dayArr.sort((a, b) => {
                    if (Number(a.weekNo) < Number(b.weekNo)) return -1;
                    if (Number(a.weekNo) > Number(b.weekNo)) return 1;
                    if (a.dayTime < b.dayTime) return -1;
                    if (a.dayTime > b.dayTime) return 1;
                    return 0;
                });
                // console.log(dayArr, 'dayArr');
                this.setState({
                    // weekNo: 1,
                    // selectValue: "",
                    AKeyDayList: dayArr,
                    addWeeksVisible: false,
                    editWeeksVisible: false,
                })
            }
        } else if (timeVisible) {
            this.remindSave()
        } else if (addContentVisible) {
            this.saveRecordContent()
        } else if (exportedVisible) {
            this.statsExport()
        }
        else if (exportedRecordVisible) {
            this.recordBatchExport()
        } else if (addContentPop) {
            this.saveWeekContent()
        }

        // this.setState({
        //     timeVisible: false,
        //     exportedVisible: false,
        //     addWeeksVisible: false,
        // });
    }

    // 提醒日期选择
    onChange = (checked, index) => {
        let timeList = this.state.timeRanges.concat([]); //2023-07-05将group修改为group1
        const newData = [...timeList];
        timeList[index].checked = checked;
        this.setState(
            {
                timeRanges: newData,
            },
            () => {
                // this.props.setReleaseScope(newData);
            }
        );
    };

    // 切换模板
    editTemplate = (type, id) => {
        let { templateType, isManage, timeoutId } = this.state;

        if (type !== templateType) {
            this.setState({
                templateType: type,
                setGrouper: true,
            });

            // 清除之前的延迟执行任务
            if (timeoutId) {
                clearTimeout(timeoutId);
            }

            // 设置新的延迟执行任务
            const newTimeoutId = setTimeout(() => {
                if (isManage != 1) {
                    this.setState({
                        selectedKeys: id,
                    }, () => {
                        this.getWeekDetail();
                    });
                }
            }, 300); // 设置延迟时间，单位毫秒

            // 更新 timeoutId 到 state 中，以便之后清除
            this.setState({
                timeoutId: newTimeoutId,
            });
        }
    };


    //menu导航
    handleClick = (e, type) => {
        console.log(type, "click ", e, 'e.item.props.key2', e.item.props.key2);
        if (type === "1") {
            this.setState(
                {
                    selectedKeys: e.key,
                    departmentSelectId: e.item.props.key2
                },
                () => {
                    this.getWeekDetail();
                }
            );
        } else {
            this.setState(
                {
                    selectedKeys1: e.key,
                },
                () => {
                    this.getRecordMgtDetail();
                }
            );
        }
    };

    alertDelete = (item, type, event) => {
        if (event) {
            event.stopPropagation();
            event.preventDefault();
        }
        let alert = lgAlert.show({
            duration: 0,
            content: <span>确定要{type === "delWeek" || type === 'delRecord' || type === 'delContent' ? "删除" : "撤回"}{type === "delWeek" ? <span style={{ color: '#ff6600' }}>{'"' + item.arrangementName + '"'}</span>
                : type === "delContent" ? <span style={{ color: '#ff6600' }}>{'"' + item.content + '"'}</span> : '记录表'}吗？</span>,
            isShowCloseBtn: true,
            tipType: "question",
            tipSize: "small",
            tipMouldType: "A",
            confirmText: "确定",
            closeText: "再想想",
            showCover: true,
            coverZIndex: 1000,
            coverOpacity: 0.25,
            onConfirm: () => {
                if (type === "delWeek") {
                    this.deleteWeeklyDayPlay(item);
                } else if (type === 'delRecord') {
                    this.deleteRecordMgt();
                } else if (type === 'delContent') {
                    this.addContent('del', item?.key)
                }
                lgAlert.close(alert.index);
            },
        });
    };

    alertPersonEdit = () => {
        let {
            teacherTimeData,
            selectTime,
            weekDay,
            selectUserListAKey,
            remindPersonList,
        } = this.state
        const content = (<div className="remind_div">
            <div>
                是否将<span style={{ color: '#ff6600' }}>"{moment(selectTime).format('YYYY/MM/DD') + '(' + weekDay + ')'}"</span>的值{teacherTimeData.type === '1' ? '周' : '日'}记录提交给指定用户查看？
            </div>
            <div className="week_person_div">
                <div>
                    {selectUserListAKey.length > 0
                        ? selectUserListAKey.slice(0, 10).map((item, index) => {
                            return (
                                <div className="selected-one" key={index}>
                                    {item.name || item.userName}
                                    {item.userId ? (
                                        <span
                                            style={{
                                                color: "#999",
                                            }}
                                        >
                                            ({item.userId})
                                        </span>
                                    ) : item.groupType ? (
                                        <>
                                            <span
                                                style={{
                                                    color: "#999",
                                                }}
                                            >
                                                ({groupTypeInfo[item.groupType]})
                                            </span>
                                            {item?.totalCount ? (
                                                <span
                                                    style={{
                                                        color: "#999",
                                                    }}
                                                >
                                                    ({item.totalCount}人)
                                                </span>
                                            ) : (
                                                ""
                                            )}
                                        </>
                                    ) : (
                                        ""
                                    )}
                                    <i
                                        className="delete-logo"
                                        onClick={() => {
                                            this.deleteSelectedUser(index, 3)
                                            lgAlert.close(alert.index);
                                        }
                                        }
                                    ></i>
                                </div>
                            );
                        })
                        : ""}
                    {selectUserListAKey.length > 10 ? (
                        <span
                            style={{
                                float: "left",
                                margin: "0 5px",
                                fontSize: "20px",
                                lineHeight: "20px",
                            }}
                        >
                            ...
                        </span>
                    ) : (
                        ""
                    )}
                </div>
                <div
                    className="week_person_btn"
                    style={{
                        marginTop: selectUserListAKey.length > 0 ? "" : "18px",
                    }}
                >
                    {selectUserListAKey.length > 0 ? (
                        <span className="duty_person">
                            已选
                            <span className="duty_num">
                                {selectUserListAKey.length}
                            </span>
                            人
                        </span>
                    ) : (
                        ""
                    )}
                    <LgButton
                        className="duty_open_select"
                        onClick={() => {
                            this.setState({ selectUserVisibleAKey: true });
                            lgAlert.close(alert.index);
                        }}
                        size="mini"
                        backgroundType="translucent"
                        border
                        type="info"
                    >
                        {selectUserListAKey.length > 0 ? "修改" : "选择"}
                    </LgButton>
                    {selectUserListAKey.length > 0 ? (
                        <LgButton
                            className="duty_empty"
                            style={{ marginLeft: '5px' }}
                            size="mini"
                            onClick={() => { this.clear(3); lgAlert.close(alert.index); }}
                            backgroundType="translucent"
                            border
                            type="fail"
                        >
                            清空
                        </LgButton>
                    ) : (
                        ""
                    )}
                </div>
            </div>
        </div>)
        let alert = lgAlert.show({
            duration: 0,
            content,
            isShowCloseBtn: true,
            tipType: "question",
            tipSize: 'big',
            tipMouldType: "A",
            confirmText: "确定",
            closeText: "再想想",
            showCover: true,
            coverZIndex: 1000,
            coverOpacity: 0.25,
            position: { xAxis: '50%', yAxis: '35%', showDirection: 'center', xOffset: '-50%' },
            onConfirm: () => {
                this.remindRecordLeader(() => lgAlert.close(alert.index));
            },
            onCancel: () => {
                this.setState({
                    selectUserListAKey: remindPersonList.concat([])
                })
                console.log(remindPersonList, 'remindPersonList');
                // lgAlert.close(alert.index);
            },
            onClose: () => {
                this.setState({
                    selectUserListAKey: remindPersonList.concat([])
                })
                // lgAlert.close(alert.index);
            },
            onIconClose: () => {
                this.setState({
                    selectUserListAKey: remindPersonList.concat([])
                })
                // lgAlert.close(alert.index);
            }
        });
    };

    //状态选择
    SelectOptionA = (item) => {
        console.log("选择的item:", item);
        this.setState(
            {
                selectValue: item.text,
                weekNo: item.weekNo,
            },
            () => {
                this.getWeekNum();
            }
        );
    };
    //获取选择对象选择的用户列表（新）
    getSelectList = (obj) => {
        let {
            selectUserVisible,
            selectUserVisibleAKey,
            selectGrouperVisibleAKey,
            arrangementIndex,
            contentIndex,
            contentUserList,
        } = this.state
        if (arrangementIndex === 2) {
            let list = contentUserList;
            list[contentIndex] = obj.selectUserList
            this.setState({
                contentUserList: list,
            })
        }
        if (selectUserVisible) {
            this.setState({
                selectUserList: obj.selectUserList,
            });
        } else if (selectUserVisibleAKey) {
            this.setState({
                selectUserListAKey: obj.selectUserList,
            });
        } else if (selectGrouperVisibleAKey) {
            this.setState({
                selectGrouperListAKey: obj.selectUserList,
            });
        }
    };

    selectUserChange = (value) => {
        let { isManage } = this.state
        //控制选择对象弹窗显隐
        this.setState(
            {
                selectUserVisible: value,
                selectUserVisibleAKey: value,
                selectGrouperVisibleAKey: value,
            },
            () => {
                if (isManage != 1) {
                    this.alertPersonEdit()
                }
                // 在状态更新后获取元素并设置样式
                // let coverLayer = document.querySelector('.lg_popLayer_container_coverLayer_show');
                // if (coverLayer) {
                //     coverLayer.style.opacity = '0.5';
                // }
            }
        );
    };
    // 清空值日人员
    clear = (type) => {
        let { isManage } = this.state
        if (type === 1) {
            this.setState({
                selectUserList: [],
            });
        }
        if (type === 2) {
            this.setState({
                selectGrouperListAKey: [],
            });
        }
        if (type === 3) {
            this.setState({
                selectUserListAKey: [],
            }, () => {
                if (isManage != 1) {
                    this.alertPersonEdit();
                }
            });
        }
    };
    deleteSelectedUser = (index, type) => {
        console.log(this.state.remindPersonList, 'remindPersonList');
        let { selectUserList, selectUserListAKey, selectGrouperListAKey, isManage } = this.state;
        if (type === 1) {
            selectUserList.splice(index, 1);
            this.setState({
                selectUserList,
            });
        }
        if (type === 2) {
            selectGrouperListAKey.splice(index, 1);
            this.setState({
                selectGrouperListAKey,
            });
        }
        if (type === 3) {
            selectUserListAKey.splice(index, 1);
            this.setState({
                selectUserListAKey,
            }, () => {
                if (isManage != 1) {
                    this.alertPersonEdit();
                }
            });
        }
    };
    // 搜索用户
    onSearch = (value) => {
        console.log("搜索值:", value);
        let { userInfo } = this.state;
        if (value == '') return;
        getData("/api/common/user//noPage/searchUser", {
            schoolId: userInfo.schoolId,
            schoolLevel: userInfo.schoolLevel,
            userName: value,
            appid: 252,
            filerUserType: "0,1,11",
        })
            .then((data) => {
                return data.json();
            })
            .then((json) => {
                if (json.code == "200") {
                    let data = json.data;
                    data.forEach((item) => {
                        item.text = item.userName + "(" + item.userId + ")";
                    });
                    this.setState({
                        grouperList: data,
                    });
                } else {
                    message.error(json.msg, 3);
                }
            });
    };
    // 值周队长选择
    SelectOptionB = (item) => {
        console.log("选择的item:", item);
        this.setState({
            selectGrouper: item.text,
            leaderId: item.userId,
        });
    };

    // 选择关联的值日/值周表
    checkRecord = (index, checked) => {
        let { WeekOrDayPlayList } = this.state;
        let arr = WeekOrDayPlayList.concat([]);
        arr[index].check = !checked;
        this.setState({
            WeekOrDayPlayList: arr,
        });
    };

    // 下一步
    nextStep = () => {
        let {
            step,
            AKeyWeekList,
            weekDetail,
            selectUserListAKey,
            selectGrouperListAKey,
            isEasy,
            contentArr,
            explicit,
            routine,
            AKeyDayList,
        } = this.state
        if (step === 1) {
            if (AKeyWeekList.length === 0 && weekDetail.typeOf === '1') {
                message.warn('请先安排周次！');
                return;
            } else if (AKeyDayList.length === 0 && weekDetail.typeOf === '2') {
                message.warn('请先安排日期！');
                return;
            } else {
                this.setState({
                    step: step + 1,
                    selectValue: '',
                    weekNo: 1,
                })
            }
        } else if (step === 2) {
            if (weekDetail.beLeader === '1' && weekDetail.typeOf === '1') {
                if (selectGrouperListAKey.length === 0) {
                    message.warn('请先安排值周组长！');
                    return;
                }
            }
            if (selectUserListAKey.length === 0) {
                message.warn(`请先安排值${explicit || routine ? '日' : '周'}人员！`);
                return;
            }
            if (!isEasy && !routine && contentArr.length === 0) {
                message.warn(`请先安排值${explicit || routine ? '日' : '周'}内容！`);
                return;
            }
            this.setPersonnelSchedule();
        } else {
            this.oneKeyScheduling();
        }
    }

    // 上一步
    lastStep = () => {
        let {
            step
        } = this.state
        if (step > 1) {
            this.setState({
                step: step - 1
            })
        } else {
            this.setState({
                popLayerAKey: false,
            })
        }
    }

    deleteWeek = (idx, type) => {
        let {
            AKeyWeekList,

        } = this.state
        let delArr = [...AKeyWeekList];
        delArr.splice(idx, 1);

        if (type === 'aKeyDel') {
            this.setState({
                AKeyWeekList: delArr,
            })
        }

    }

    // 选择每周值周人数
    SelectOptionC = (item) => {
        console.log("选择的item:", item);
        this.setState(
            {
                selectValue: item.text,
                weekNo: item.weekNo,
            },
            () => {
                this.getWeekNum();
            }
        );
    };

    // 记录查询选择记录表
    SelectOptionD = (item) => {
        console.log("选择的item:", item);
        this.setState(
            {
                selectRecordValue: item.text,
                selectRecordIndex: item.idx,
                selectRecordId: item.recordMgtId,
            },
            () => {
                this.calendarForManage();
            }
        );
    };

    // 数据统计切换查询记录表
    SelectOptionE = (item) => {
        console.log("选择的item:", item);
        this.setState(
            {
                statisticsValue: item.text,
                statisticsIndex: item.idx,
                statisticsId: item.recordMgtId,
            },
            () => {
                this.getWorkload();
            }
        );
    };

    // 输入框修改值周表名称
    handleInputChangeName = (e) => {
        const { typingTimeout } = this.state;

        // 清除之前的计时器
        clearTimeout(typingTimeout);

        // 设置新的计时器来延迟调用 createWeek
        const timeoutId = setTimeout(() => {
            this.createWeek('', '', true, true);
        }, 3000); // 3000 毫秒即 3 秒

        // 更新状态
        this.setState({
            arrangementInputName: e.currentTarget.value,
            typingTimeout: timeoutId
        });
    };
    // 输入框输入值周要求
    handleInputChange = (e) => {
        const { typingTimeout } = this.state;

        // 清除之前的计时器
        clearTimeout(typingTimeout);

        // 设置新的计时器来延迟调用 createWeek
        const timeoutId = setTimeout(() => {
            this.createWeek('', '', true);
        }, 3000); // 3000 毫秒即 3 秒

        // 更新状态
        this.setState({
            textareaValue: e.currentTarget.value,
            typingTimeout: timeoutId
        });
    };

    //添加值周/值日内容
    addContent = (type, index) => {
        let { contentValue, contentArr } = this.state;

        if (type === 'ok') {
            if (contentValue == '') {
                message.warn('请输入内容!');
                return;
            }
            // 使用concat方法创建一个新的数组，并将contentValue添加进去
            let newContentArr = contentArr.concat(contentValue);
            if (newContentArr.length > 5) {
                message.warn('最多设置五条内容~');
                return;
            }
            // console.log(newContentArr,'newContentArr');
            this.setState({
                contentArr: newContentArr,
                contentValue: '',   // 清空输入框
                isAddContent: false // 关闭添加内容的状态
            });
        } else if (type === 'false') {
            this.setState({
                contentValue: '',   // 清空输入框
                isAddContent: false // 关闭添加内容的状态
            });
        } else {
            contentArr.splice(index, 1);
            this.setState({
                contentArr,
            }, () => {
                this.saveWeekContent('del')
            });
        }
    }

    // 图表
    getChartOptions = () => {
        let {
            situation
        } = this.state

        let data = situation.map(item => item.content);
        let normalArr = situation.map(item => item.normalTimes);
        let otherArr = situation.map(item => item.otherTimes);

        let option = {
            tooltip: {
                trigger: 'axis',
                axisPointer: {
                    type: 'shadow',
                    shadowStyle: {
                        color: 'rgba(0,0,0,0)'
                    },
                },
                backgroundColor: 'rgba(0, 0, 0, 0.72)',
                borderWidth: 0,
                borderColor: 'rgba(0, 0, 0, 0.72)',
                textStyle: {
                    color: '#fff',
                    fontWeight: 'normal',
                }
            },
            legend: {},
            grid: {
                left: '0%',
                right: '10%',
                bottom: '3%',
                containLabel: true
            },
            xAxis: {
                type: 'value',
                name: '次数',
                nameTextStyle: {  // x轴name的样式调整
                    padding: [0, 0, 0, 0] // 加上padding可以调整其位置
                },
                nameLocation: 'end',  // 名称显示位置，end 表示末尾
                nameGap: 10,          // 名称与轴线之间的距离
                axisLabel: {
                    textStyle: {
                        color: '#999999'
                    }
                },
                axisTick: {
                    show: false
                },
                axisLine: {
                    lineStyle: {
                        color: '#cccccc',
                    }
                },
                // boundaryGap: [0, 0.01]
            },
            yAxis: {
                type: 'category',
                name: '事项',
                data,
                axisLine: {
                    show: false,
                    lineStyle: {
                        color: '#cccccc'
                    }
                },
                axisTick: {
                    show: false
                },
                splitLine: {
                    lineStyle: {
                        color: '#f1f1f1'
                    }
                },
                axisLabel: {
                    textStyle: {
                        color: '#666666'
                    },
                    formatter: function (value) {
                        // 示例：在每个标签后面加上空格
                        return value + ' ';
                    }
                }
            },
            series: [
                {
                    name: '正常',
                    type: 'bar',
                    data: normalArr,
                    stack: 'Ad',
                    emphasis: {
                        focus: 'series'
                    },
                    itemStyle: {
                        color: '#20a5fe',
                        borderRadius: [0, 3, 3, 0]
                    }
                },
                {
                    name: '其他',
                    type: 'bar',
                    data: otherArr,
                    stack: 'Ad',
                    emphasis: {
                        focus: 'series'
                    },
                    itemStyle: {
                        borderRadius: [0, 3, 3, 0],
                        normal: {
                            color: '#ffb92d',
                            barBorderRadius: [0, 9, 1, 0],//柱状颜色和圆角（顺时针左上，右上，右下，左下）
                        }
                    }
                }
            ]
        }
        this.setState({
            option
        })
    }
    // 跳转到记录表管理
    openRecordManege = (id) => {
        let token = getQueryVariable('lg_tk') || sessionStorage.getItem('token');
        let url = getRealPath() + '?lg_tk=' + token + '&recordMgtId=' + id + '&isRecord=1&lg_ic=' + getQueryVariable('lg_ic') + (sessionStorage.getItem('isManage') == 1 ? '&isManage=1' : '')
        window.open(url, '_blank');
    }

    // 导入导出
    // 值周/值日安排导入模板下载
    downloadTemplate = () => {
        let { weekDetail } = this.state;
        getData("/api/dw/v2/import/download/weekOrDayPlayImportTemplate", {
            templateId: weekDetail.templateId,
            type: weekDetail.typeOf,
        })
            .then((res) => {
                if (res.ok) {
                    return (res.blob());
                } else {
                    throw new Error('下载失败，请重试！');
                }
            })
            .then((blob) => {
                // 创建下载链接
                let downloadUrl = URL.createObjectURL(blob);

                // 创建 <a> 元素并设置下载链接
                let link = document.createElement('a');
                link.href = downloadUrl;
                let fileName = 'template.xls';
                let templateId = weekDetail.templateId;

                if (weekDetail.typeOf === '1') {
                    if (templateId.includes("week_1")) {
                        fileName = '标准值周导入模板.xls'
                    } else {
                        fileName = '极简值周导入模板.xls'
                    }
                } else {
                    if (templateId.includes("day_1")) {
                        fileName = '轮流值日导入模板.xls'
                    } else if (templateId.includes("day_2")) {
                        fileName = '常规值日导入模板.xls'
                    } else {
                        fileName = '职责明确值日导入模板.xls'
                    }
                }

                link.download = fileName; // 设置下载文件名

                // 模拟点击下载
                link.click();

                // 释放下载链接资源
                URL.revokeObjectURL(downloadUrl);
                this.setState({
                    downLoading: false
                })
            })
    }

    // 值周/值日安排导出
    weekOrDayPlayExport = () => {
        let { weekDetail, userInfo, termInfo, departmentSelectId, } = this.state;
        getData("/api/dw/v2/export/weekOrDayPlayExport", {
            schoolId: userInfo.schoolId,
            semester: termInfo.term,
            arrangementId: weekDetail.arrangementId,
            departmentId: departmentSelectId,
        })
            .then((res) => {
                if (res.ok) {
                    return (res.blob());
                } else {
                    throw new Error('导出失败，请重试！');
                }
            })
            .then((blob) => {
                // 创建下载链接
                let downloadUrl = URL.createObjectURL(blob);

                // 创建 <a> 元素并设置下载链接
                let link = document.createElement('a');
                link.href = downloadUrl;
                let arrangementName = weekDetail.arrangementName;
                let fileName = `${arrangementName}.xls`;

                link.download = fileName; // 设置下载文件名

                // 模拟点击下载
                link.click();

                // 释放下载链接资源
                URL.revokeObjectURL(downloadUrl);

                this.setState({
                    downLoading: false
                })
            })
    }

    //统计导出
    statsExport = () => {
        let { userInfo, termInfo, statisticsId, exportStartTime, exportEndTime, statisticsValue, radioValue } = this.state;
        let date = {}
        if (radioValue !== 3) {
            date = this.getDateRange();
        }
        // console.log(date, 'date');
        // console.log(statisticsStartDate, 'statisticsStartDate', statisticsEndDate, 'timeList', radioValue);
        getData("/api/dw/v2/export/statsExport", {
            schoolId: userInfo.schoolId,
            semester: termInfo.term,
            recordMgtId: statisticsId,
            startTime: radioValue === 3 ? moment(exportStartTime).format('YYYY-MM-DD HH:mm:ss') : moment(date.start).format('YYYY-MM-DD 00:00:00'),
            endTime: radioValue === 3 ? moment(exportEndTime).format('YYYY-MM-DD HH:mm:ss') : moment(date.end).format('YYYY-MM-DD 23:59:59'),
        })
            .then((res) => {
                if (res.ok) {
                    return (res.blob());
                } else {
                    throw new Error('导出失败，请重试！');
                }
            })
            .then((blob) => {
                // 创建下载链接
                let downloadUrl = URL.createObjectURL(blob);

                // 创建 <a> 元素并设置下载链接
                let link = document.createElement('a');
                link.href = downloadUrl;
                let fileName = `${statisticsValue + '-' + radioValue === 0 ? '周' : radioValue === 1 ? '月' : radioValue === 2 ? '学期' : '自定义'}.xls`;

                link.download = fileName; // 设置下载文件名

                // 模拟点击下载
                link.click();

                // 释放下载链接资源
                URL.revokeObjectURL(downloadUrl);
                this.setState({
                    exportedVisible: false
                })
                this.setState({
                    downLoading: false
                })
            })
    }

    // 获取本周/本月/本学期时间
    getDateRange = () => {
        let { radioValue, termInfo } = this.state
        const now = new Date();

        if (radioValue === 0) {
            // 获取本周的开始和结束日期
            const dayOfWeek = now.getDay();
            const startOfWeek = new Date(now);
            startOfWeek.setDate(now.getDate() - dayOfWeek + 1); // 周一

            const endOfWeek = new Date(now);
            endOfWeek.setDate(now.getDate() + (7 - dayOfWeek)); // 周日

            return {
                start: startOfWeek.toLocaleDateString(),
                end: endOfWeek.toLocaleDateString()
            };
        } else if (radioValue === 1) {
            // 获取本月的开始和结束日期
            const startOfMonth = new Date(now.getFullYear(), now.getMonth(), 1);
            const endOfMonth = new Date(now.getFullYear(), now.getMonth() + 1, 0);

            return {
                start: startOfMonth.toLocaleDateString(),
                end: endOfMonth.toLocaleDateString()
            };
        } else if (radioValue === 2) {
            return {
                start: termInfo.termStartDate,
                end: termInfo.termEndDate,
            };
        } else {
            throw new Error('Invalid radioValue. Use 0 for week or 1 for month.');
        }
    }

    //记录导出
    recordExport = (name = null) => {
        let { weekDetail, userInfo, termInfo, isManage, recordId, selectRecordValue, selectTime } = this.state;
        if (!recordId) {
            message.warn('没有选择相关记录');
            return;
        }
        getData("/api/dw/v2/export/recordExport", {
            schoolId: userInfo.schoolId,
            semester: termInfo.term,
            recordId,
            userId: userInfo.userId,
            clientType: isManage == 1 ? 1 : 2
        })
            .then((res) => {
                if (res.ok) {
                    return (res.blob());
                } else {
                    throw new Error('导出失败，请重试！');
                }
            })
            .then((blob) => {
                // 创建下载链接
                let downloadUrl = URL.createObjectURL(blob);

                // 创建 <a> 元素并设置下载链接
                let link = document.createElement('a');
                link.href = downloadUrl;
                let fileName = `${(name ? name : selectRecordValue) + '-' + moment(selectTime).format('YYYY-MM-DD')}.xls`;

                link.download = fileName; // 设置下载文件名

                // 模拟点击下载
                link.click();

                // 释放下载链接资源
                URL.revokeObjectURL(downloadUrl);
                this.setState({
                    downLoading: false
                })
            })
    }

    //记录批量导出
    recordBatchExport = () => {
        let { userInfo, selectRecordId, recordMgtId, termInfo, selectRecordValue, exportStartTime, exportEndTime, radioValue } = this.state;
        let date = {};
        if (radioValue !== 3) {
            date = this.getDateRange();
        }
        // console.log(selectRecordId, '123', recordMgtId);

        getData("/api/dw/v2/export/recordBatchExport", {
            schoolId: userInfo.schoolId,
            semester: termInfo.term,
            recordMgtId: selectRecordId,
            startTime: radioValue === 3 ? moment(exportStartTime).format('YYYY-MM-DD HH:mm:ss') : moment(date.start).format('YYYY-MM-DD 00:00:00'),
            endTime: radioValue === 3 ? moment(exportEndTime).format('YYYY-MM-DD HH:mm:ss') : moment(date.end).format('YYYY-MM-DD 23:59:59'),
        })
            .then((res) => {
                if (res.ok) {
                    return res.blob(); // 处理成功响应
                } else {
                    // 读取错误信息
                    return res.text().then((text) => {
                        try {
                            const errorData = JSON.parse(text);
                            const errorMessage = errorData.message || '导出失败，所选日期没有相关记录！';
                            message.warn(errorMessage);
                            throw new Error(errorMessage);
                        } catch (e) {
                            throw new Error('导出失败，无法解析错误信息！');
                        }
                    });
                }
            })
            .then((blob) => {
                // 创建下载链接
                let downloadUrl = URL.createObjectURL(blob);

                // 创建 <a> 元素并设置下载链接
                let link = document.createElement('a');
                link.href = downloadUrl;
                let fileName = `${selectRecordValue + '-' + (radioValue === 0 ? '周' : radioValue === 1 ? '月' : radioValue === 2 ? '学期' : '自定义')}.xls`;

                link.download = fileName; // 设置下载文件名

                // 模拟点击下载
                link.click();

                // 释放下载链接资源
                URL.revokeObjectURL(downloadUrl);
                this.setState({
                    exportedRecordVisible: false,
                    downLoading: false
                });
            })
            .catch((error) => {
                // 处理错误
                console.error('导出失败:', error.message);
                // 显示错误提示
                this.setState({
                    downLoading: false
                });
            });
    }


    render() {
        let {
            loading,
            datalist,
            dark,
            open,
            tabList,
            defaultTabIndex,
            textareaValue,
            typeIndex,
            dutyArr,
            popLayer01,
            popLayer02,
            popLayer03,
            popLayer04,
            popLayer05,
            popLayerAKey,
            popLayerRecord,
            timeRanges,
            timeVisible,
            exportedVisible,
            exportedRecordVisible,
            radioValue,
            timeList,
            statisticsVisible,
            isManage,
            weekList,
            templateList,
            templateType,
            setGrouper,
            termInfo,
            selectedKeys,
            weekDetail,
            recordSheetList,
            selectedKeys1,
            weekSheetDetail,
            cycleList,
            selectValue,
            start,
            end,
            selectUserVisible,
            selectUserList,
            schoolSystemInfo,
            selectGrouper,
            grouperList,
            WeekOrDayPlayList,
            recordTableName,
            addWeeksVisible,
            AKeyWeekList,
            step,
            arrangementOfWay,
            editWeeksVisible,
            selectUserVisibleAKey,
            selectGrouperVisibleAKey,
            selectUserListAKey,
            selectGrouperListAKey,
            dutyPersonNum,
            isEasy,
            setScheduleResult,
            setResultList,
            calendarData,
            requireList,
            selectRecordValue,
            selectRecordIndex,
            statisticsList,
            statisticsValue,
            statisticsIndex,
            statisticsStartDate,
            statisticsEndDate,
            isAddContent,
            contentValue,
            contentArr,
            contentNumber,
            remindValue,
            remindList,
            timeReminder,
            addContentVisible,
            addContentValue,
            weekSheetDetail1,
            weekSheetDetail2,
            takeTurns,
            takeTurnsValue,
            dayTime,
            routine,
            explicit,
            recordId,
            selectTime,
            workload,
            situation,
            option,
            viewportHeight,
            popLayerEditRecord,
            myWeeklyData,
            userInfo,
            teacherRecordPop,
            teacherTimeData,
            weekDay,
            bindRecord,
            setContentPop,
            AKeyDayList,
            dayTimeAKey,
            arrangementInputName,
            editName,
            exportStartTime,
            exportEndTime,
            importVisible,
            startDay,
            endDay,
            weekNo,
            weekId,
            dayId,
            arrangementIndex,
            contentIndex,
            contentUserList,
            departmentList,
            departmentValue,
            departmentIndex,
            addContentPop,
            editContentVisible,
            textareaRequireValue,
            workloadDetailPop,
            workloadDetailList,
            workloadUser,
            typeList,
            typeSelect,
            typeSelectIndex,
            isDep,
        } = this.state;
        console.log(contentArr, 'contentArr');

        let isWeek = weekDetail && weekDetail.typeOf === '1' ? '周' : '日'
        return (
            <LgBlockCardBox className={"g002-bg" + (loading ? "is-loading" : "")}>
                {isManage == 1 ? (
                    <LgSideBarA
                        datalist={datalist}
                        dark={dark}
                        open={open}
                        darkChange={this.darkChange}
                        openChange={this.openChange}
                        update={this.update}
                        selectedItem={this.selectedItem}
                    >
                        <LgTabs
                            data={tabList}
                            position="top"
                            closable={true}
                            type="card"
                            contentIsShow={false}
                            onCloseClick={this.onCloseTab}
                            onTabClick={this.onTabClick}
                            defaultTabIndex={defaultTabIndex}
                        ></LgTabs>
                        {selectUserVisible || selectUserVisibleAKey || selectGrouperVisibleAKey ? (
                            <SelectUserModal
                                className="select-user-item"
                                title={selectGrouperVisibleAKey ? '选择值周组长' : `选择值${isWeek}人员`}
                                // groupUserType={['0','1']}
                                baseUrl={schoolSystemInfo.itemUrl} //http://192.168.122.124:22101/office-platform/
                                // baseUrl={'https://xdtest.aiedu100.com/office-platform/'} //http://192.168.122.124:22101/office-platform/
                                token={
                                    sessionStorage.getItem("token") || getQueryVariable("lg_tk")
                                }
                                visible={selectUserVisible || selectUserVisibleAKey || selectGrouperVisibleAKey}
                                getSelectResult={this.getSelectList}
                                selectList={selectUserVisible ? selectUserList : selectUserVisibleAKey ? selectUserListAKey : selectGrouperListAKey}
                                groupUserType={["0", "1", "11"]}
                                changeVisible={this.selectUserChange}
                                maxLength={selectGrouperVisibleAKey ? 12 : 40}
                                schoolId={userInfo?.schoolId}
                            />
                        ) : (
                            ""
                        )}
                        {/* 直接使用 LgTabs 中的内容区域设置出来的内容有部分问题，直接移出到LgTabs组件外 */}
                        {datalist[0].selected ? (
                            <div className="content_container">
                                <div className="top_tip">
                                    <i className="tips_cion"></i>共
                                    <span style={{ color: "#333333" }}>{dutyArr.length}</span>
                                    个分组值周值日表
                                </div>
                                <div className="bottom_container">
                                    <div className="bottom_left">
                                        <Scrollbars
                                            autoHeight
                                            autoHide
                                            autoHideTimeout={100}
                                            style={{
                                                height: "calc(100% - 102px)",
                                                minHeight: "calc(100% - 102px)",
                                            }}
                                            autoHeightMin={"100%"}
                                        >
                                            {dutyArr.length > 0 ? (
                                                <Menu
                                                    onClick={(e) => this.handleClick(e, "1")}
                                                    style={{ width: 162 }}
                                                    defaultSelectedKeys={["all"]}
                                                    defaultOpenKeys={["sub1"]}
                                                    mode="inline"
                                                    selectedKeys={selectedKeys}
                                                >
                                                    {dutyArr.map((item, index) => {
                                                        return (
                                                            <Menu.Item key={item.arrangementId} key2={item?.departmentId || ''}>
                                                                <div className="menu_item_title">
                                                                    <div
                                                                        className="duty_title"
                                                                        title={item.arrangementName}
                                                                    >
                                                                        {item.arrangementName}
                                                                    </div>
                                                                    <i
                                                                        className="delete_icon"
                                                                        onClick={(e) =>
                                                                            this.alertDelete(item, "delWeek", e)
                                                                        }
                                                                    ></i>
                                                                    <div className="duty_department">{item?.departmentName || '未设置部门'}</div>
                                                                    <div className="duty_type">
                                                                        {item.typeOf == 1 ? (
                                                                            <div className="duty_type_title">
                                                                                <div className="duty_week">值周</div>
                                                                                <div className="line"></div>
                                                                                <div>{item.times}周</div>
                                                                            </div>
                                                                        ) : (
                                                                            <div className="duty_day_title">值日</div>
                                                                        )}
                                                                    </div>
                                                                </div>
                                                            </Menu.Item>
                                                        );
                                                    })}
                                                </Menu>
                                            ) : (
                                                <div className="empty_div">
                                                    {" "}
                                                    <LgEmpty>暂无值周值日表</LgEmpty>
                                                </div>
                                            )}
                                        </Scrollbars>
                                        <div className="btn_left">
                                            <LgButton
                                                onClick={() => this.openDrawer("addWeekTable")}
                                                backgroundType="translucent"
                                                border
                                                type="info"
                                            >
                                                创建值周安排表
                                            </LgButton>
                                            <LgButton
                                                onClick={() => this.openDrawer("addDayTable")}
                                                backgroundType="translucent"
                                                border
                                                type="warning"
                                                className="btn_day"
                                            >
                                                创建值日安排表
                                            </LgButton>
                                        </div>
                                    </div>
                                    {weekDetail !== null ? (
                                        <div className="bottom_right">
                                            <div className="bottom_right_top">
                                                <div className="top_left">
                                                    {
                                                        editName
                                                            ?
                                                            <LgInput
                                                                className="name_input"
                                                                maxLength={20}
                                                                value={arrangementInputName}
                                                                onChange={(e) => {
                                                                    this.handleInputChangeName(e)
                                                                    // this.setState({
                                                                    //     arrangementInputName: e.currentTarget.value,
                                                                    // });
                                                                }}
                                                            ></LgInput>
                                                            : <span className="edit_name" onClick={() => this.setState({ editName: true })}>{arrangementInputName}</span>
                                                    }
                                                    <div
                                                        className={
                                                            "left_duty_week " +
                                                            (weekDetail.typeOf == "1" ? "" : "left_duty_day")
                                                        }
                                                    >
                                                        {weekDetail.typeOf == "1" ? "值周" : "值日"}
                                                    </div>
                                                </div>
                                                <div className="top_right">
                                                    <LgButton
                                                        className="top_right_btn"
                                                        backgroundType="transparent"
                                                        border
                                                        showIcon
                                                        icon={
                                                            <LgButton.icon.Download></LgButton.icon.Download>
                                                        }
                                                        type="info"
                                                        onClick={() => this.setState({
                                                            importVisible: true
                                                        })}
                                                    >
                                                        导入
                                                    </LgButton>
                                                    <LgButton
                                                        className="top_right_btn"
                                                        backgroundType="transparent"
                                                        border
                                                        showIcon
                                                        icon={<LgButton.icon.Share></LgButton.icon.Share>}
                                                        type="info"
                                                        onClick={() => this.weekOrDayPlayExport()}
                                                    >
                                                        导出
                                                    </LgButton>
                                                    <LgButton
                                                        className="top_right_btn"
                                                        backgroundType="translucent"
                                                        border
                                                        showIcon
                                                        icon={<i className="icon_remind"></i>}
                                                        type="info"
                                                        onClick={() => this.remindTeacher()}
                                                    >
                                                        提醒今日老师值{isWeek}
                                                    </LgButton>
                                                    <LgButton
                                                        onClick={() => this.openDrawer("reminder")}
                                                        className="top_right_btn"
                                                        backgroundType="opacification"
                                                        gradient
                                                        showIcon
                                                        icon={<i className="icon_remind_set"></i>}
                                                        type="info"
                                                    >
                                                        提醒设置
                                                    </LgButton>
                                                    <LgButton
                                                        onClick={() => this.openDrawer("log")}
                                                        className="top_right_btn"
                                                        backgroundType="opacification"
                                                        gradient
                                                        showIcon
                                                        icon={<i className="icon_record_set"></i>}
                                                        type="info"
                                                    >
                                                        记录表设置
                                                    </LgButton>
                                                </div>
                                            </div>
                                            <div className="bottom_right_bottom">
                                                <div className="table_top">
                                                    <div className="table_top_left">
                                                        <div className="green_line"></div>
                                                        人员安排
                                                        {weekDetail.typeOf == "1" ? (
                                                            <>
                                                                <span style={{ color: "#999" }}>（共</span>
                                                                {weekDetail.times}
                                                                <span style={{ color: "#999" }}>周）</span>
                                                            </>
                                                        ) : (
                                                            ""
                                                        )}
                                                    </div>
                                                    <div className="table_top_right">
                                                        {
                                                            explicit || (!isEasy && weekDetail.typeOf == "1") ?
                                                                <LgButton
                                                                    onClick={() => this.openDrawer("setContent")}
                                                                    backgroundType="opacification"
                                                                    gradient
                                                                    icon={<LgButton.icon.Edit></LgButton.icon.Edit>}
                                                                    showIcon
                                                                    type="info"
                                                                    className="set_content"
                                                                >
                                                                    值{explicit ? '日' : '周'}内容设置
                                                                </LgButton>
                                                                : ''
                                                        }
                                                        {
                                                            takeTurns ?
                                                                ''
                                                                :
                                                                <LgButton
                                                                    onClick={() => this.openDrawer("aKeyScheduling")}
                                                                    backgroundType="opacification"
                                                                    gradient
                                                                    type="info"
                                                                >
                                                                    一键排班
                                                                </LgButton>
                                                        }
                                                        <LgButton
                                                            className="right_btn"
                                                            backgroundType="opacification"
                                                            gradient
                                                            type="success"
                                                            onClick={() => this.openDrawer("addWeek")}
                                                        >
                                                            {takeTurns ? '安排人员' : explicit || routine ? '添加日期' : '添加周次'}
                                                        </LgButton>
                                                    </div>
                                                </div>
                                                <div className="table_middle ">
                                                    <LgTable
                                                        type={weekDetail?.typeOf === '1' ? "weekTable" : 'dayTable'}
                                                        weeklyPlayList={weekDetail?.weeklyPlayList}
                                                        dayPlayList={weekDetail?.dayPlayList}
                                                        recallPerson={this.recallPerson}
                                                        deletePerson={this.deletePerson}
                                                        editWeek={this.openDrawer}
                                                        publish={this.savePersonnel}
                                                        remindTeacherByPlay={this.remindTeacherByPlay}
                                                        autoHeightMax={viewportHeight}
                                                        isEasy={isEasy}
                                                        takeTurns={takeTurns}
                                                        routine={routine}
                                                        explicit={explicit}
                                                    ></LgTable>
                                                </div>
                                                <div className="table_bottom">
                                                    <div className="table_bottom_top">
                                                        <div className="green_line"></div>
                                                        值{isWeek}要求
                                                    </div>
                                                    <div className="table_bottom_bottom">
                                                        <LgTextarea
                                                            numberOfWords
                                                            className="textarea-warp"
                                                            value={textareaValue}
                                                            placeholder={`请输入值${isWeek}要求...`}
                                                            textarea={{
                                                                onInput: this.handleInputChange,
                                                                // onInput: (e) => {
                                                                //     this.setState(
                                                                //         {
                                                                //             textareaValue: e.currentTarget.value,
                                                                //         },
                                                                //         () => { this.createWeek()}
                                                                //     );
                                                                // },
                                                                maxLength: 200,
                                                            }}
                                                            currentTextQuantity={textareaValue.length}
                                                        />
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    ) : (
                                        <div className="bottom_right bottom_right_empty">
                                            <LgEmpty size="large">请先选择/创建值周值日表</LgEmpty>
                                        </div>
                                    )}
                                </div>
                            </div>
                        ) : datalist[1].selected ? (
                            <div className="content_container">
                                <div className="top_tip">
                                    <i className="tips_cion"></i>共
                                    <span style={{ color: "#333333" }}>
                                        {recordSheetList.length}
                                    </span>
                                    个分组记录表
                                </div>
                                <div className="bottom_container">
                                    <div className="bottom_left record_table_management">
                                        <Scrollbars
                                            autoHeight
                                            autoHide
                                            autoHideTimeout={100}
                                            style={{
                                                height: "calc(100% - 60px)",
                                                minHeight: "calc(100% - 60px)",
                                            }}
                                            autoHeightMin={"100%"}
                                        >
                                            {recordSheetList.length > 0 ? (
                                                <Menu
                                                    onClick={(e) => this.handleClick(e, "2")}
                                                    style={{ width: 162 }}
                                                    defaultSelectedKeys={["all"]}
                                                    defaultOpenKeys={["sub1"]}
                                                    mode="inline"
                                                    selectedKeys={selectedKeys1}
                                                    className="week_sheet_menu"
                                                >
                                                    {recordSheetList.map((item, index) => {
                                                        return (
                                                            <Menu.Item key={item.recordMgtId}>
                                                                <div className="menu_item_title">
                                                                    <div
                                                                        className="duty_title"
                                                                        title={item.recordMgtName}
                                                                    >
                                                                        {item.recordMgtName}
                                                                    </div>
                                                                </div>
                                                            </Menu.Item>
                                                        );
                                                    })}
                                                </Menu>
                                            ) : (
                                                <div className="empty_div">
                                                    {" "}
                                                    <LgEmpty>暂无记录表</LgEmpty>
                                                </div>
                                            )}
                                        </Scrollbars>
                                        <div className="btn_left">
                                            <LgButton
                                                onClick={() => this.openDrawer("addRecordTable")}
                                                backgroundType="translucent"
                                                border
                                                type="info"
                                            >
                                                添加记录表
                                            </LgButton>
                                        </div>
                                    </div>
                                    {weekSheetDetail !== null ? (
                                        <div className="bottom_right">
                                            <div className="bottom_right_top record_table_top">
                                                <div className="top_left">
                                                    {weekSheetDetail.recordMgtName}
                                                    {/* <div
                                                        className={
                                                            "left_duty_week " +
                                                            (weekDetail.typeOf == "1" ? "" : "left_duty_day")
                                                        }
                                                    >
                                                        {weekDetail.typeOf == "1" ? "值周" : "值日"}
                                                    </div> */}
                                                </div>
                                                <div className="top_right">
                                                    {/* <LgButton
                                                        className="top_right_btn"
                                                        backgroundType="transparent"
                                                        border
                                                        showIcon
                                                        icon={<LgButton.icon.Share></LgButton.icon.Share>}
                                                        type="info"
                                                        onClick={() => this.recordExport()}
                                                    >
                                                        导出
                                                    </LgButton> */}
                                                    <LgButton
                                                        className="top_right_btn"
                                                        backgroundType="translucent"
                                                        showIcon
                                                        border
                                                        icon={<LgButton.icon.Delete></LgButton.icon.Delete>}
                                                        type="fail"

                                                        onClick={() => this.alertDelete(weekSheetDetail, 'delRecord')}
                                                    >
                                                        删除
                                                    </LgButton>
                                                </div>
                                            </div>
                                            <div className="bottom_right_bottom record_table_bottom">
                                                <div className="table_top">
                                                    <div className="table_top_left">
                                                        <span style={{ color: "#999" }}>
                                                            绑定值周值日安排表:{" "}
                                                        </span>
                                                        {weekSheetDetail.resultString}
                                                        <i className="edit_icon" onClick={() => this.openDrawer('editRecordTable')}></i>
                                                    </div>
                                                </div>
                                                <div className="table_middle" style={{ height: 'inherit' }}>
                                                    <RecordTable viewportHeight={viewportHeight} haveTop={false} openPop={() => this.setState({ addContentVisible: true })} weekSheetDetail={weekSheetDetail}></RecordTable>
                                                </div>
                                                <div className="table_bottom table_bottom_btn">
                                                    {/* <LgButton
                                                        className="import_btn"
                                                        backgroundType="transparent"
                                                        border
                                                        type="info"
                                                    >
                                                        导入
                                                    </LgButton> */}
                                                    {/* <LgButton
                                                        backgroundType="opacification"
                                                        gradient
                                                        type="info"
                                                    >
                                                        值周提醒设置
                                                    </LgButton> */}
                                                </div>
                                            </div>
                                        </div>
                                    ) : (
                                        <div className="bottom_right bottom_right_empty">
                                            <LgEmpty size="large">请先选择/创建记录表！</LgEmpty>
                                        </div>
                                    )}
                                </div>
                            </div>
                        ) : datalist[2].selected ? (
                            <div className="content_container">
                                <div className="top_container">
                                    <LgSelect
                                        SelectOption={this.SelectOptionD}
                                        datalist={requireList}
                                        value={selectRecordValue}
                                        indexArr={[selectRecordIndex]}
                                        className="require_select"
                                    ></LgSelect>
                                    <div>
                                        {/* {
                                            recordId ? */}
                                        <LgButton
                                            onClick={() => this.openPop("exportedRecord")}
                                            // onClick={() => this.recordExport()}
                                            backgroundType="transparent"
                                            border
                                            showIcon
                                            icon={<LgButton.icon.Share></LgButton.icon.Share>}
                                            type="info"
                                        >
                                            导出
                                        </LgButton>
                                        {/* : ''
                                        } */}
                                        <LgButton
                                            onClick={() => this.openDrawer("log1")}
                                            className="top_btn_right"
                                            backgroundType="opacification"
                                            showIcon
                                            gradient
                                            icon={<LgButton.icon.Time></LgButton.icon.Time>}
                                            type="info"
                                        >
                                            记录表设置
                                        </LgButton>
                                    </div>
                                </div>
                                <div className="bottom_container record_query">
                                    <div className={"bottom_left time_range " + (calendarData?.calendarVoList ? '' : 'no_time_range')}>
                                        {
                                            calendarData?.calendarVoList ?
                                                <Scrollbars
                                                    autoHeight
                                                    autoHide
                                                    autoHideTimeout={100}
                                                    style={{
                                                        height: "calc(100% - 30px)",
                                                        minHeight: "calc(100% - 30px)",
                                                    }}
                                                    autoHeightMin={"100%"}
                                                    ref={this.scrollbarsRef}
                                                >
                                                    <Calendar recordInfoDetail={this.recordInfoDetail} calendarVoList={calendarData.calendarVoList}></Calendar>
                                                </Scrollbars>
                                                :
                                                <LgEmpty size="large">暂无记录表，请先创建！</LgEmpty>
                                        }
                                    </div>
                                    <div className="bottom_right record_query_right">
                                        {
                                            calendarData?.calendarVoList ?
                                                <div >
                                                    <RecordTable headerName={selectRecordValue} selectTime={selectTime} haveTop={true} viewportHeight={viewportHeight} recordExport={this.recordExport}
                                                        weekSheetDetail={recordId ? weekSheetDetail2 : weekSheetDetail1} recordInfoDetail={this.recordInfoDetail}></RecordTable>
                                                </div>
                                                :
                                                <div className="no_record_table">
                                                    <LgEmpty size="large">请先选择/创建记录表！</LgEmpty>
                                                </div>
                                        }
                                    </div>
                                </div>
                            </div>
                        ) : (
                            <div className="content_container">
                                <div className="statistics_top">
                                    <div className="statistics_top_left">
                                        <LgSelect className="statistics_select"
                                            SelectOption={this.SelectOptionE}
                                            datalist={statisticsList}
                                            value={statisticsValue}
                                            indexArr={[statisticsIndex]}
                                        ></LgSelect>
                                        <LgDatePicker
                                            type="B"
                                            value={[statisticsStartDate, statisticsEndDate]}
                                            format='yyyy/MM/dd'
                                            pickerOptions={{
                                                disabledDate(time) {
                                                    // 设置不可选择的日期范围
                                                    return time.getTime() < Date.now() - 8.64e7; // 示例：禁止选择今天之前的日期
                                                }
                                            }}
                                            onChange={(e) => {
                                                if (e instanceof Array) {
                                                    this.setState({
                                                        statisticsStartDate: e[0],
                                                        statisticsEndDate: e[1]
                                                    }, () => this.getWorkload())
                                                    console.log("start:", e[0], "end:", e[1]);
                                                }
                                            }}
                                        ></LgDatePicker>
                                    </div>
                                    <div className="statistics_top_right">
                                        <LgButton
                                            onClick={() => this.openPop("exported")}
                                            // onClick={() => this.statsExport()}
                                            backgroundType="transparent"
                                            border
                                            showIcon
                                            icon={<LgButton.icon.Share></LgButton.icon.Share>}
                                            type="info"
                                        >
                                            导出
                                        </LgButton>
                                    </div>
                                </div>
                                <div className="statistics_bottom">
                                    <div className="statistics_bottom_left">
                                        <LgBlockCard
                                            title="工作量统计"
                                            supplement={
                                                <span>
                                                    共<span style={{ color: "#333" }}>{workload.length}</span>名教师
                                                </span>
                                            }
                                        >
                                            <LgTable type={"workload"} workload={workload} getWorkloadDetail={this.getWorkloadDetail}></LgTable>
                                        </LgBlockCard>
                                    </div>
                                    <div className="statistics_bottom_right">
                                        <LgBlockCard title="值周/值日情况统计" className="statistics_charts">
                                            <ReactEcharts
                                                option={option}
                                                notMerge={true}
                                                lazyUpdate={true}
                                                style={{ height: "calc(100% - 28px)", minHeight: '200px', width: 'calc(100% - 10px)' }}
                                            />
                                        </LgBlockCard>
                                    </div>
                                </div>
                            </div>
                        )}
                        <LgDrawer
                            cover
                            title={
                                popLayer01
                                    ? takeTurns ? '安排人员' : explicit || routine ? dayId != '' ? '编辑日期' : '添加日期' : weekId != '' ? '编辑周次' : '添加周次'
                                    : popLayer02
                                        ? "值周记录表设置"
                                        : popLayer03
                                            ? "值周提醒设置"
                                            : popLayer04
                                                ? "创建值周安排表"
                                                : popLayer05
                                                    ? "创建值日安排表"
                                                    : popLayerAKey
                                                        ? "一键排班"
                                                        : popLayerRecord
                                                            ? "添加记录表"
                                                            : popLayerEditRecord ? '编辑记录表' : setContentPop ? `值${explicit ? '日' : '周'}内容设置` :
                                                                workloadDetailPop ? `值周值日统计详情-${workloadUser}` : ""
                            }
                            type={"right"}
                            style={{ position: "absolute" }}
                            zIndex={20000}
                            visible={
                                popLayer01 ||
                                popLayer02 ||
                                popLayer03 ||
                                popLayer04 ||
                                popLayer05 ||
                                popLayerAKey ||
                                popLayerRecord ||
                                popLayerEditRecord ||
                                setContentPop ||
                                workloadDetailPop
                            }
                            closeBtn={this.cancelDrawer}
                            checkBtn={this.confirmDrawer}
                            className={
                                "pop_seven drawer-modal " +
                                (popLayer02
                                    ? "week_set_pop"
                                    : popLayer03 || popLayer04 || popLayer05 || popLayerAKey
                                        ? "reminder_set_pop"
                                        : setContentPop ? 'content_set_pop' : "")
                            }
                            width={
                                popLayer01 || popLayer02
                                    ? 640
                                    : popLayer03 ||
                                        popLayer04 ||
                                        popLayer05 ||
                                        popLayerAKey ||
                                        popLayerRecord ||
                                        popLayerEditRecord ||
                                        setContentPop ||
                                        workloadDetailPop
                                        ? 850
                                        : 640
                            }
                            darken={false}
                        >
                            {popLayer01 ? (
                                <div className="btn_div">
                                    <LgButton
                                        backgroundType="opacification"
                                        type="success"
                                        onClick={() => this.savePersonnel((weekDetail.typeOf === '1' ? 'saveWeek' : 'saveDay'), 1)}
                                    >
                                        发布
                                    </LgButton>
                                    <LgButton
                                        backgroundType="opacification"
                                        type="info"
                                        onClick={() => this.savePersonnel((weekDetail.typeOf === '1' ? 'saveWeek' : 'saveDay'), 0)}
                                        className="save_btn"
                                    >
                                        保存
                                    </LgButton>
                                    <LgButton
                                        backgroundType="transparent"
                                        border
                                        type="info"
                                        onClick={() => this.cancelDrawer()}
                                    >
                                        取消
                                    </LgButton>
                                </div>
                            ) : (
                                ""
                            )}
                            {popLayer01 ? (
                                <div className="add_week_div">
                                    <div className="week_info_div">
                                        <span className="add_week_span">
                                            <span style={{ color: "red" }}>*</span> {takeTurns ? '组别:' : '周次:'}
                                        </span>
                                        {
                                            takeTurns ?
                                                <LgInputNumber value={takeTurnsValue} onChange={(value) => {
                                                    this.setState({
                                                        takeTurnsValue: value,
                                                    });
                                                }} size='small' max={99} min={1}></LgInputNumber>
                                                :
                                                <LgInputNumber value={weekNo} onChange={(value) => {
                                                    this.setState({
                                                        // weekInputNumber: value,
                                                        weekNo: value,
                                                    }, () => {
                                                        if (value && value <= cycleList.length) {
                                                            this.debouncedGetWeekNum()
                                                        }
                                                    });
                                                }} size='small' max={cycleList.length} min={1}></LgInputNumber>
                                            // <LgSelect
                                            //     SelectOption={this.SelectOptionA}
                                            //     datalist={cycleList}
                                            //     value={selectValue}
                                            //     indexArr={[]}
                                            //     className="week_select"
                                            // ></LgSelect>
                                        }
                                    </div>
                                    {
                                        weekDetail.typeOf === '1' ?
                                            <div className="date_range">
                                                <span className="add_week_span">日期范围:</span>
                                                <LgDatePicker
                                                    type="B"
                                                    format='yyyy/MM/dd'
                                                    // isDisabled={true}
                                                    value={[start, end]}
                                                    disabledDate={time => time.getTime() < moment(termInfo?.termStartDate ? termInfo?.termStartDate : start).subtract(1, 'month').toDate() || time.getTime() > moment(termInfo?.termEndDate ? termInfo?.termEndDate : end).add(2, 'month').toDate()}
                                                    onChange={(e) => {
                                                        if (e instanceof Array) {
                                                            this.setState({
                                                                start: e[0],
                                                                end: e[1]
                                                            })
                                                            console.log("start:", e[0], "end:", e[1]);
                                                        }
                                                    }}
                                                />
                                            </div>
                                            :
                                            takeTurns ?
                                                <div className="date_range date_range_check">
                                                    <span className="add_week_span">值日范围:</span>
                                                    {timeRanges.map((item, index) => (
                                                        <LgCheckbox
                                                            className={
                                                                "check_item"
                                                            }
                                                            key={"checkbox" + index}
                                                            checked={item.checked}
                                                            onChange={this.onChange}
                                                            value={index}
                                                            label={item.label}
                                                        />
                                                    ))}
                                                </div>
                                                :
                                                <div className="date_range">
                                                    <span className="add_week_span">值日日期:</span>
                                                    <LgDatePicker
                                                        format='yyyy/MM/dd'
                                                        value={dayTime}
                                                        disabledDate={time => time.getTime() < moment(start).subtract(1, 'day').toDate() || time.getTime() > end}
                                                        onChange={(e) => {
                                                            this.setState({ dayTime: e })
                                                        }}
                                                    />
                                                </div>
                                    }
                                    {
                                        explicit || (!isEasy && weekDetail.typeOf === '1') ?
                                            <div className="user_content_select">人员安排：
                                                <div>
                                                    <LgRadio.Group value={arrangementIndex} onChange={nextValue => this.setState({
                                                        arrangementIndex: nextValue,
                                                        selectUserList: nextValue === 2 ? contentUserList[contentIndex] : [],
                                                        // contentIndex: 0,
                                                    })}>
                                                        <LgRadio className="g006-form-1-item" value={1}>自动均分人员到每个内容</LgRadio>
                                                        <LgRadio className="g006-form-1-item" value={2}>自选人员安排到每个内容</LgRadio>
                                                    </LgRadio.Group>
                                                </div>
                                            </div>
                                            : ''
                                    }
                                    {
                                        explicit || (!isEasy && weekDetail.typeOf === '1') ?
                                            <div className="arrangement_mode arrangement_mode_div" >{!isEasy ? '值周内容' : '值日内容'}：
                                                <div className="content_item_div">
                                                    {contentArr.length === 0 ? (
                                                        <span style={{ color: '#999' }}>暂无安排内容<LgButton onClick={() => this.setState({
                                                            popLayer01: false,
                                                            arrangementIndex: 1,
                                                            contentIndex: 0,
                                                            contentUserList: [[], [], [], [], []],
                                                        }, () => this.openDrawer("setContent"))} type='info' shapeType='text' style={{ marginLeft: '10px' }}>去设置</LgButton></span>
                                                    ) : (
                                                        contentArr.map((item, index) => (
                                                            <div key={index} className="content_item" style={{
                                                                cursor: arrangementIndex === 2 ? 'pointer' : '',
                                                                borderColor: arrangementIndex === 2 && index == contentIndex ? '#0099ff' : ''
                                                            }}
                                                                onClick={() => {
                                                                    if (arrangementIndex === 2) {
                                                                        this.setState({
                                                                            contentIndex: index,
                                                                            selectUserList: contentUserList[index],
                                                                        })
                                                                    }
                                                                }
                                                                }
                                                            >
                                                                {item?.content}
                                                                {/* 如果需要添加删除功能，可以取消注释下一行 */}
                                                                {/* <i className="content_item_del" onClick={() => this.addContent('del', index)}></i> */}
                                                            </div>
                                                        ))
                                                    )}
                                                    {/* {
                                                        isAddContent ?
                                                            <div className="content_add_div">
                                                                <LgInput
                                                                    className="content_input"
                                                                    maxLength={15}
                                                                    value={contentValue}
                                                                    onChange={(e) => {
                                                                        this.setState({
                                                                            contentValue: e.currentTarget.value,
                                                                        });
                                                                    }}
                                                                ></LgInput>
                                                                <div className="is_ok" onClick={() => this.addContent('ok')}>√</div>
                                                                <div className="is_false" onClick={() => this.addContent('false')}>X</div>
                                                            </div>
                                                            :
                                                            <div className="add_content" onClick={() => this.setState({ isAddContent: true })}>添加内容</div>
                                                    } */}
                                                </div>
                                            </div>
                                            : ''
                                    }
                                    {weekDetail.beLeader === "1" && weekDetail.typeOf === '1' ? (
                                        <div style={{ marginTop: !isEasy ? '12px' : '' }}>
                                            <span className="add_week_span">值周队长:</span>
                                            <LgSelect
                                                datalist={grouperList}
                                                value={selectGrouper}
                                                openSearch={true}
                                                onSearch={this.onSearch}
                                                SelectOption={this.SelectOptionB}
                                            ></LgSelect>
                                        </div>
                                    ) : (
                                        ""
                                    )}

                                    <div className="duty_week_person">
                                        <span className="add_week_span">值{isWeek}人员:</span>
                                        <div className="week_person_div">
                                            <div>
                                                {selectUserList && selectUserList.length > 0
                                                    ? selectUserList.slice(0, 10).map((item, index) => {
                                                        return (
                                                            <div className="selected-one" key={index}>
                                                                {item.name || item.userName}
                                                                {item.userId ? (
                                                                    <span
                                                                        style={{
                                                                            color: "#999",
                                                                        }}
                                                                    >
                                                                        ({item.userId})
                                                                    </span>
                                                                ) : item.groupType ? (
                                                                    <>
                                                                        <span
                                                                            style={{
                                                                                color: "#999",
                                                                            }}
                                                                        >
                                                                            ({groupTypeInfo[item.groupType]})
                                                                        </span>
                                                                        {item?.totalCount ? (
                                                                            <span
                                                                                style={{
                                                                                    color: "#999",
                                                                                }}
                                                                            >
                                                                                ({item.totalCount}人)
                                                                            </span>
                                                                        ) : (
                                                                            ""
                                                                        )}
                                                                    </>
                                                                ) : (
                                                                    ""
                                                                )}
                                                                <i
                                                                    className="delete-logo"
                                                                    onClick={() =>
                                                                        this.deleteSelectedUser(index, 1)
                                                                    }
                                                                ></i>
                                                            </div>
                                                        );
                                                    })
                                                    : ""}
                                                {selectUserList && selectUserList.length > 10 ? (
                                                    <span
                                                        style={{
                                                            float: "left",
                                                            margin: "0 5px",
                                                            fontSize: "20px",
                                                            lineHeight: "20px",
                                                        }}
                                                    >
                                                        ...
                                                    </span>
                                                ) : (
                                                    ""
                                                )}
                                            </div>
                                            <div
                                                className="week_person_btn"
                                                style={{
                                                    marginTop: selectUserList && selectUserList.length > 0 ? "" : "18px",
                                                }}
                                            >
                                                {selectUserList && selectUserList.length > 0 ? (
                                                    <span className="duty_person">
                                                        已选
                                                        <span className="duty_num">
                                                            {selectUserList ? selectUserList.length : 0}
                                                        </span>
                                                        人
                                                    </span>
                                                ) : (
                                                    ""
                                                )}
                                                <LgButton
                                                    className="duty_open_select"
                                                    onClick={() => {
                                                        this.setState({ selectUserVisible: true });
                                                    }}
                                                    size="mini"
                                                    backgroundType="translucent"
                                                    border
                                                    type="info"
                                                >
                                                    {selectUserList && selectUserList.length > 0 ? "修改" : "选择"}
                                                </LgButton>
                                                {selectUserList && selectUserList.length > 0 ? (
                                                    <LgButton
                                                        className="duty_empty"
                                                        style={{ marginLeft: '5px' }}
                                                        size="mini"
                                                        onClick={() => this.clear(1)}
                                                        backgroundType="translucent"
                                                        border
                                                        type="fail"
                                                    >
                                                        清空
                                                    </LgButton>
                                                ) : (
                                                    ""
                                                )}
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            ) : popLayer02 ? (
                                <div className="weekly_record_table">
                                    <div className="weekly_table_top">
                                        <div>
                                            <span className="weekly_table_span">
                                                当前值周/值日记录表：
                                                <LgButton textUnderline type='info' shapeType='text' onClick={() => this.openRecordManege(bindRecord?.recordMgtId || '')}>    {
                                                    bindRecord ? '《' + bindRecord.recordMgtName + '》' : '暂无记录表，点击前往新增记录表'
                                                }</LgButton>
                                                <span className="weekly_table_tip">

                                                </span>
                                            </span>
                                        </div>
                                        <LgButton
                                            backgroundType="opacification"
                                            showIcon
                                            icon={<LgButton.icon.Add></LgButton.icon.Add>}
                                            type="success"
                                            onClick={() => this.openRecordManege('')}
                                        >
                                            添加记录表
                                        </LgButton>
                                    </div>
                                    <div className="weekly_table_bottom">
                                        <span className="tips_span">
                                            提示:新增记录表时，可选择值周记录表进行绑定，智能关联填写人员，由值周
                                            人员填写对应日期的记录表。
                                            <span className="tips_record">
                                                ( {
                                                    bindRecord ? '点击打开新页面，定位至记录表模块，并定位至该记录表'
                                                        : '点击打开新页面，定位至记录表模块，打开新增记录表弹窗'
                                                })
                                            </span>
                                        </span>
                                        {/* <LgTable
                                            type={"recordList"}
                                            recordList={recordSheetList}
                                        ></LgTable> */}
                                    </div>
                                </div>
                            ) : popLayer03 ? (
                                <div className="weekly_reminder_settings">
                                    <div className="weekly_reminder_top">
                                        <span className="weekly_reminder_span">
                                            系统会在“发布值周安排后”、“值周开始前1天下午14:00”、“值周当天早上05:00”等时间段通过微信公众号提醒值周人员参与值周。
                                            此外，您还可以添加提醒时间{" "}
                                            {/* <LgButton
                                                className="view_examples"
                                                type="info"
                                                shapeType="text"
                                            >
                                                查看示例
                                            </LgButton> */}
                                        </span>
                                    </div>
                                    <div className="weekly_reminder_bottom">
                                        <div className="reminder_bottom_top">
                                            <div style={{ color: "#999" }}>
                                                共<span style={{ color: "#333" }}>{remindList.length}</span>条
                                            </div>
                                            <LgButton
                                                onClick={() => this.openPop("addReminderTime")}
                                                backgroundType="opacification"
                                                showIcon
                                                icon={<LgButton.icon.Add></LgButton.icon.Add>}
                                                type="success"
                                            >
                                                添加提醒时间
                                            </LgButton>
                                        </div>
                                        <div className="reminder_bottom_bottom">
                                            <LgTable
                                                type={"reminderTable"}
                                                remindList={remindList}
                                                editRemind={this.openPop}
                                                delRemindItem={this.delRemindItem}
                                            ></LgTable>
                                        </div>
                                    </div>
                                </div>
                            ) : popLayer04 ? (
                                <div className="create_weekly_schedule">
                                    <div className="create_weekly_left">
                                        <div className="weekly_left_top">请选择模板:</div>
                                        <div
                                            className="weekly_left_middle"
                                            onClick={() => this.editTemplate(0)}
                                        >
                                            <div
                                                className={
                                                    "minimal_template " +
                                                    (templateType === 0 ? "active" : "")
                                                }
                                            ></div>
                                            <div className="template_span">极简模板</div>
                                        </div>
                                        <div
                                            className="weekly_left_bottom"
                                            onClick={() => this.editTemplate(1)}
                                        >
                                            <div
                                                className={
                                                    "standard_template " +
                                                    (templateType === 1 ? "active" : "")
                                                }
                                            ></div>
                                            <div className="template_span">标准模板</div>
                                        </div>
                                    </div>
                                    <div className="create_weekly_right">
                                        <div className="weekly_right_dep">
                                            <div className="weekly_department">值周部门:</div>
                                            <div className="weekly_department_select">
                                                <LgSelect
                                                    SelectOption={this.SelectDepartment}
                                                    datalist={departmentList}
                                                    value={departmentValue}
                                                    indexArr={[departmentIndex]}
                                                    className="department_select"
                                                    placeholder={isDep == '1' ? '请选择部门...' : '请选择部门(非必选)...'}
                                                ></LgSelect></div>
                                            <div className="weekly_department_tips">{isDep == '1' ? '' : '提示: 部门负责人管理本部门安排表，未指定部门则管理员统一管理。'}</div>
                                        </div>
                                        <div className="weekly_right_top">
                                            {templateType === 0 ? (
                                                <>
                                                    <div className="template_name">
                                                        {templateList[0]?.templateName}
                                                    </div>
                                                    <div className="template_name_bottom">
                                                        <LgSwitch
                                                            checked={setGrouper}
                                                            onClick={() =>
                                                                this.setState({
                                                                    setGrouper: !setGrouper,
                                                                })
                                                            }
                                                        />
                                                        <span className="set_grouper">设置值周组长</span>
                                                        {templateList[0]?.description.map((item, index) => {
                                                            return (
                                                                <span
                                                                    className={
                                                                        "template_tip template_tip_" + index
                                                                    }
                                                                >
                                                                    {item}
                                                                </span>
                                                            );
                                                        })}
                                                    </div>
                                                </>
                                            ) : (
                                                <>
                                                    <div className="template_name">
                                                        {templateList[1]?.templateName}
                                                    </div>
                                                    <div className="template_name_bottom">
                                                        <LgSwitch
                                                            checked={setGrouper}
                                                            onClick={() =>
                                                                this.setState({
                                                                    setGrouper: !setGrouper,
                                                                })
                                                            }
                                                        />
                                                        <span className="set_grouper">设置值周组长</span>
                                                        {templateList[1]?.description.map((item, index) => {
                                                            return (
                                                                <span
                                                                    className={
                                                                        "template_tip template_tip_" + index
                                                                    }
                                                                >
                                                                    {item}
                                                                </span>
                                                            );
                                                        })}
                                                    </div>
                                                </>
                                            )}
                                        </div>
                                        <div className="weekly_right_bottom">
                                            <div className="preview_div">预览效果</div>
                                            <div className="preview_table_name">
                                                {termInfo.term.slice(0, -2) +
                                                    "学年" +
                                                    (termInfo.term.slice(-2) == "01" ? "春季" : "秋季") +
                                                    "值周安排表"}
                                            </div>
                                            <LgTable
                                                type={"template"}
                                                setGrouper={setGrouper}
                                                templateType={templateType}
                                            ></LgTable>
                                            <div className="tip_div">
                                                <div>值周要求：</div>
                                                <div>1. 请值周老师按时上岗值周；</div>
                                                <div>2. 如有事要请假请提前安排好换班。</div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            ) : popLayer05 ? (
                                <div className="create_weekly_schedule">
                                    <div className="create_weekly_left">
                                        <div className="weekly_left_top">请选择模板:</div>
                                        <div
                                            className="weekly_left_middle"
                                            onClick={() => this.editTemplate(0)}
                                        >
                                            <div
                                                className={
                                                    "standard_template " +
                                                    (templateType === 0 ? "active" : "")
                                                }
                                            ></div>
                                            <div className="template_span">轮流值日模板</div>
                                        </div>
                                        <div
                                            className="weekly_left_bottom"
                                            onClick={() => this.editTemplate(1)}
                                        >
                                            <div
                                                className={
                                                    "standard_template " +
                                                    (templateType === 1 ? "active" : "")
                                                }
                                            ></div>
                                            <div className="template_span">常规值日模板</div>
                                        </div>
                                        <div
                                            className="weekly_left_bottom"
                                            onClick={() => this.editTemplate(2)}
                                        >
                                            <div
                                                className={
                                                    "standard_template " +
                                                    (templateType === 2 ? "active" : "")
                                                }
                                            ></div>
                                            <div className="template_span">职责明确值日模板</div>
                                        </div>
                                    </div>
                                    <div className="create_weekly_right">
                                        <div className="weekly_right_dep">
                                            <div className="weekly_department">值日部门:</div>
                                            <div className="weekly_department_select">
                                                <LgSelect
                                                    SelectOption={this.SelectDepartment}
                                                    datalist={departmentList}
                                                    value={departmentValue}
                                                    indexArr={[departmentIndex]}
                                                    className="department_select"
                                                    placeholder={isDep == '1' ? '请选择部门...' : '请选择部门(非必选)...'}
                                                ></LgSelect></div>
                                            <div className="weekly_department_tips">{isDep == '1' ? '' : '提示: 部门负责人管理本部门安排表，未指定部门则管理员统一管理。'}</div>
                                        </div>
                                        <div className="weekly_right_top">
                                            {templateType === 0 ? (
                                                <>
                                                    <div className="template_name">
                                                        {templateList[0]?.templateName}
                                                    </div>
                                                    <div className="template_name_bottom">
                                                        {/* <LgSwitch
                                                            checked={setGrouper}
                                                            onClick={() =>
                                                                this.setState({
                                                                    setGrouper: !setGrouper,
                                                                })
                                                            }
                                                        />
                                                        <span className="set_grouper">设置值周组长</span> */}
                                                        {templateList[0]?.description.map((item, index) => {
                                                            return (
                                                                <span
                                                                    className={
                                                                        "template_tip template_tip_num1 template_tip_" + index
                                                                    }
                                                                >
                                                                    {item}
                                                                </span>
                                                            );
                                                        })}
                                                    </div>
                                                </>
                                            ) : templateType === 1 ? (
                                                <>
                                                    <div className="template_name">
                                                        {templateList[1]?.templateName}
                                                    </div>
                                                    <div className="template_name_bottom">
                                                        {/* <LgSwitch
                                                            checked={setGrouper}
                                                            onClick={() =>
                                                                this.setState({
                                                                    setGrouper: !setGrouper,
                                                                })
                                                            }
                                                        />
                                                        <span className="set_grouper">设置值周组长</span> */}
                                                        {templateList[1]?.description.map((item, index) => {
                                                            return (
                                                                <span
                                                                    className={
                                                                        "template_tip template_tip_num1 template_tip_" + index
                                                                    }
                                                                >
                                                                    {item}
                                                                </span>
                                                            );
                                                        })}
                                                    </div>
                                                </>
                                            ) :
                                                templateType === 2 ?
                                                    (
                                                        <>
                                                            <div className="template_name">
                                                                {templateList[2]?.templateName}
                                                            </div>
                                                            <div className="template_name_bottom">
                                                                {/* <LgSwitch
                                                                    checked={setGrouper}
                                                                    onClick={() =>
                                                                        this.setState({
                                                                            setGrouper: !setGrouper,
                                                                        })
                                                                    }
                                                                />
                                                                <span className="set_grouper">设置值周组长</span> */}
                                                                {templateList[2]?.description.map((item, index) => {
                                                                    return (
                                                                        <span
                                                                            className={
                                                                                "template_tip template_tip_num1 template_tip_" + index
                                                                            }
                                                                        >
                                                                            {item}
                                                                        </span>
                                                                    );
                                                                })}
                                                            </div>
                                                        </>
                                                    )
                                                    :
                                                    (
                                                        <>
                                                            <div className="template_name">
                                                                {templateList[1]?.templateName}
                                                            </div>
                                                            <div className="template_name_bottom">
                                                                <LgSwitch
                                                                    checked={setGrouper}
                                                                    onClick={() =>
                                                                        this.setState({
                                                                            setGrouper: !setGrouper,
                                                                        })
                                                                    }
                                                                />
                                                                <span className="set_grouper">设置值周组长</span>
                                                                {templateList[1]?.description.map((item, index) => {
                                                                    return (
                                                                        <span
                                                                            className={
                                                                                "template_tip template_tip_" + index
                                                                            }
                                                                        >
                                                                            {item}
                                                                        </span>
                                                                    );
                                                                })}
                                                            </div>
                                                        </>
                                                    )}
                                        </div>
                                        <div className="weekly_right_bottom">
                                            <div className="preview_div">预览效果</div>
                                            <div className="preview_table_name">
                                                {termInfo.term.slice(0, -2) +
                                                    "学年" +
                                                    (termInfo.term.slice(-2) == "01" ? "春季" : "秋季") +
                                                    (popLayer05 ? '值日安排表' : "值周安排表")}
                                            </div>
                                            <LgTable
                                                type={"templateDay"}
                                                templateType={templateType}
                                            ></LgTable>
                                            <div className="tip_div">
                                                <div>值周要求：</div>
                                                <div>1. 请值周老师按时上岗值周；</div>
                                                <div>2. 如有事要请假请提前安排好换班。</div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            ) : popLayerAKey ? (
                                <div className="a_key_schedule">
                                    <div className="a_key_top">
                                        <div className="a_key_progress">
                                            <div className={"progress_1 " + (step === 1 ? 'progress_active' : 'progress_finish')}>1.确认{explicit || routine ? '值日' : '周次'}时间</div>
                                            <div className={"progress_2 " + (step === 2 ? 'progress_active' : step === 3 ? 'progress_finish' : '')}>2.设置人员及规则</div>
                                            <div className={"progress_3 " + (step === 3 ? 'progress_active' : '')}>3.确认排班结果</div>
                                        </div>
                                    </div>
                                    {
                                        step === 1 ?
                                            <div className="a_key_bottom">
                                                <div className="a_key_bottom_top">
                                                    <div style={{ color: "#999" }}>
                                                        共
                                                        <span style={{ color: "#333" }}>
                                                            {weekDetail.typeOf === '1' ? AKeyWeekList.length : AKeyDayList.length}
                                                        </span>
                                                        {
                                                            explicit || routine ?
                                                                '日' :
                                                                '周'
                                                        }
                                                    </div>
                                                    <LgButton
                                                        backgroundType="opacification"
                                                        showIcon
                                                        icon={<LgButton.icon.Add></LgButton.icon.Add>}
                                                        type="success"
                                                        onClick={() => this.openPop("addWeeks")}
                                                    >
                                                        添加{explicit || routine ? '日期' : '周次'}
                                                    </LgButton>
                                                </div>
                                                <div className="a_key_bottom_bottom">
                                                    <LgTable
                                                        type={explicit || routine ? 'aKeyDay' : "aKey"}
                                                        explicit={explicit}
                                                        routine={routine}
                                                        AKeyWeekList={AKeyWeekList}
                                                        AKeyDayList={AKeyDayList}
                                                        editWeek={this.openPop}
                                                        deleteWeek={this.deleteWeek}
                                                        isEasy={true}
                                                        emptyText={`还没有安排${explicit || routine ? '日期' : '周次'}，请先安排！`}
                                                    ></LgTable>
                                                </div>
                                            </div>
                                            : step === 2 ?
                                                <div className="a_key_bottom a_key_bottom2">
                                                    <div className="a_key_bottom_top a_key_step2">
                                                        <div className="set_week_person">
                                                            设置值{isWeek}人员
                                                        </div>
                                                        {
                                                            weekDetail.beLeader === '1' && weekDetail.typeOf === '1' ?
                                                                <div className="set_person">
                                                                    <span className="add_week_span">值{isWeek}组长:</span>
                                                                    <div className="week_person_div">
                                                                        <div>
                                                                            {selectGrouperListAKey.length > 0
                                                                                ? selectGrouperListAKey.slice(0, 10).map((item, index) => {
                                                                                    return (
                                                                                        <div className="selected-one" key={index}>
                                                                                            {item.name || item.userName}
                                                                                            {item.userId ? (
                                                                                                <span
                                                                                                    style={{
                                                                                                        color: "#999",
                                                                                                    }}
                                                                                                >
                                                                                                    ({item.userId})
                                                                                                </span>
                                                                                            ) : item.groupType ? (
                                                                                                <>
                                                                                                    <span
                                                                                                        style={{
                                                                                                            color: "#999",
                                                                                                        }}
                                                                                                    >
                                                                                                        ({groupTypeInfo[item.groupType]})
                                                                                                    </span>
                                                                                                    {item?.totalCount ? (
                                                                                                        <span
                                                                                                            style={{
                                                                                                                color: "#999",
                                                                                                            }}
                                                                                                        >
                                                                                                            ({item.totalCount}人)
                                                                                                        </span>
                                                                                                    ) : (
                                                                                                        ""
                                                                                                    )}
                                                                                                </>
                                                                                            ) : (
                                                                                                ""
                                                                                            )}
                                                                                            <i
                                                                                                className="delete-logo"
                                                                                                onClick={() =>
                                                                                                    this.deleteSelectedUser(index, 2)
                                                                                                }
                                                                                            ></i>
                                                                                        </div>
                                                                                    );
                                                                                })
                                                                                : ""}
                                                                            {selectGrouperListAKey.length > 10 ? (
                                                                                <span
                                                                                    style={{
                                                                                        float: "left",
                                                                                        margin: "0 5px",
                                                                                        fontSize: "20px",
                                                                                        lineHeight: "20px",
                                                                                    }}
                                                                                >
                                                                                    ...
                                                                                </span>
                                                                            ) : (
                                                                                ""
                                                                            )}
                                                                        </div>
                                                                        <div
                                                                            className="week_person_btn"
                                                                            style={{
                                                                                marginTop: selectGrouperListAKey.length > 0 ? "" : "18px",
                                                                            }}
                                                                        >
                                                                            {selectGrouperListAKey.length > 0 ? (
                                                                                <span className="duty_person">
                                                                                    已选
                                                                                    <span className="duty_num">
                                                                                        {selectGrouperListAKey.length}
                                                                                    </span>
                                                                                    人
                                                                                </span>
                                                                            ) : (
                                                                                ""
                                                                            )}
                                                                            <LgButton
                                                                                className="duty_open_select"
                                                                                onClick={() => {
                                                                                    this.setState({ selectGrouperVisibleAKey: true });
                                                                                }}
                                                                                size="mini"
                                                                                backgroundType="translucent"
                                                                                border
                                                                                type="info"
                                                                            >
                                                                                {selectGrouperListAKey.length > 0 ? "修改" : "选择"}
                                                                            </LgButton>
                                                                            {selectGrouperListAKey.length > 0 ? (
                                                                                <LgButton
                                                                                    className="duty_empty"
                                                                                    style={{ marginLeft: '5px' }}
                                                                                    size="mini"
                                                                                    onClick={() => this.clear(2)}
                                                                                    backgroundType="translucent"
                                                                                    border
                                                                                    type="fail"
                                                                                >
                                                                                    清空
                                                                                </LgButton>
                                                                            ) : (
                                                                                ""
                                                                            )}
                                                                        </div>
                                                                    </div>
                                                                </div>
                                                                : ''
                                                        }
                                                        <div className="set_person">
                                                            <span className="add_week_span">值周人员:</span>
                                                            <div className="week_person_div">
                                                                <div>
                                                                    {selectUserListAKey.length > 0
                                                                        ? selectUserListAKey.slice(0, 10).map((item, index) => {
                                                                            return (
                                                                                <div className="selected-one" key={index}>
                                                                                    {item.name || item.userName}
                                                                                    {item.userId ? (
                                                                                        <span
                                                                                            style={{
                                                                                                color: "#999",
                                                                                            }}
                                                                                        >
                                                                                            ({item.userId})
                                                                                        </span>
                                                                                    ) : item.groupType ? (
                                                                                        <>
                                                                                            <span
                                                                                                style={{
                                                                                                    color: "#999",
                                                                                                }}
                                                                                            >
                                                                                                ({groupTypeInfo[item.groupType]})
                                                                                            </span>
                                                                                            {item?.totalCount ? (
                                                                                                <span
                                                                                                    style={{
                                                                                                        color: "#999",
                                                                                                    }}
                                                                                                >
                                                                                                    ({item.totalCount}人)
                                                                                                </span>
                                                                                            ) : (
                                                                                                ""
                                                                                            )}
                                                                                        </>
                                                                                    ) : (
                                                                                        ""
                                                                                    )}
                                                                                    <i
                                                                                        className="delete-logo"
                                                                                        onClick={() =>
                                                                                            this.deleteSelectedUser(index, 3)
                                                                                        }
                                                                                    ></i>
                                                                                </div>
                                                                            );
                                                                        })
                                                                        : ""}
                                                                    {selectUserListAKey.length > 10 ? (
                                                                        <span
                                                                            style={{
                                                                                float: "left",
                                                                                margin: "0 5px",
                                                                                fontSize: "20px",
                                                                                lineHeight: "20px",
                                                                            }}
                                                                        >
                                                                            ...
                                                                        </span>
                                                                    ) : (
                                                                        ""
                                                                    )}
                                                                </div>
                                                                <div
                                                                    className="week_person_btn"
                                                                    style={{
                                                                        marginTop: selectUserListAKey.length > 0 ? "" : "18px",
                                                                    }}
                                                                >
                                                                    {selectUserListAKey.length > 0 ? (
                                                                        <span className="duty_person">
                                                                            已选
                                                                            <span className="duty_num">
                                                                                {selectUserListAKey.length}
                                                                            </span>
                                                                            人
                                                                        </span>
                                                                    ) : (
                                                                        ""
                                                                    )}
                                                                    <LgButton
                                                                        className="duty_open_select"
                                                                        onClick={() => {
                                                                            this.setState({ selectUserVisibleAKey: true });
                                                                        }}
                                                                        size="mini"
                                                                        backgroundType="translucent"
                                                                        border
                                                                        type="info"
                                                                    >
                                                                        {selectUserListAKey.length > 0 ? "修改" : "选择"}
                                                                    </LgButton>
                                                                    {selectUserListAKey.length > 0 ? (
                                                                        <LgButton
                                                                            className="duty_empty"
                                                                            style={{ marginLeft: '5px' }}
                                                                            size="mini"
                                                                            onClick={() => this.clear(3)}
                                                                            backgroundType="translucent"
                                                                            border
                                                                            type="fail"
                                                                        >
                                                                            清空
                                                                        </LgButton>
                                                                    ) : (
                                                                        ""
                                                                    )}
                                                                </div>
                                                            </div>
                                                        </div>
                                                    </div>
                                                    <div className="a_key_bottom_bottom">
                                                        <div style={{ color: "#333", lineHeight: '20px', fontWeight: 'bold' }}>
                                                            设置值{isWeek}规则
                                                        </div>
                                                        <div className="base_rule">基础规则：<span style={{ color: '#ff6600' }}>轮流值{isWeek}</span>(根据选择的值{isWeek}人员和每{isWeek}值{isWeek}人数，轮流安排)</div>
                                                        <div className="set_person_num">每{isWeek}安排
                                                            <div className="select_num">
                                                                <LgInputNumber value={dutyPersonNum} onChange={(value) => this.setState({ dutyPersonNum: value })} size='small' max={selectUserListAKey.length > 0 ? selectUserListAKey.length : 1} min={1}></LgInputNumber>
                                                            </div>
                                                            {/* <LgSelect className="select_num" SelectOption={this.SelectOptionC}
                                                            datalist={selectNumList}
                                                            value={selectNumValue}
                                                            indexArr={[]}></LgSelect> */}
                                                            人值{isWeek}人员</div>
                                                        <div className="arrangement_mode">安排方式：
                                                            <LgRadio.Group value={arrangementOfWay} onChange={nextValue => this.setState({
                                                                arrangementOfWay: nextValue,
                                                            })}>
                                                                <LgRadio className="g006-form-1-item" value={1}>分散安排</LgRadio>
                                                                <LgRadio className="g006-form-2-item" value={2}>集中安排</LgRadio>
                                                            </LgRadio.Group>
                                                            {/* <LgButton type='info' shapeType='text'>查看示例</LgButton> */}
                                                        </div>
                                                        {
                                                            !isEasy && !routine ?
                                                                <div className="arrangement_mode arrangement_mode_div">值{isWeek}内容：
                                                                    <div className="content_item_div">
                                                                        {
                                                                            contentArr.length > 0 ?
                                                                                contentArr.map((item, index) => (
                                                                                    <div key={index} className="content_item">
                                                                                        {item?.content}
                                                                                        {/* <i className="content_item_del" onClick={() => this.addContent('del', index)}></i> */}
                                                                                    </div>
                                                                                ))
                                                                                : <span style={{ color: '#999' }}>暂无安排内容</span>
                                                                        }
                                                                        {/* {
                                                                            isAddContent ?
                                                                                <div className="content_add_div">
                                                                                    <LgInput
                                                                                        className="content_input"
                                                                                        maxLength={15}
                                                                                        value={contentValue}
                                                                                        onChange={(e) => {
                                                                                            this.setState({
                                                                                                contentValue: e.currentTarget.value,
                                                                                            });
                                                                                        }}
                                                                                    ></LgInput>
                                                                                    <div className="is_ok" onClick={() => this.addContent('ok')}>√</div>
                                                                                    <div className="is_false" onClick={() => this.addContent('false')}>X</div>
                                                                                </div>
                                                                                :
                                                                                <div className="add_content" onClick={() => this.setState({ isAddContent: true })}>添加内容</div>
                                                                        } */}
                                                                    </div>
                                                                </div>
                                                                : ''
                                                        }
                                                        {
                                                            !isEasy && !routine ?
                                                                <div className="set_person_num">每个内容安排
                                                                    <div className="select_num">
                                                                        <LgInputNumber value={contentNumber} onChange={(value) => this.setState({ contentNumber: value })} size='small' max={5} min={1}></LgInputNumber>
                                                                    </div>
                                                                    名人员</div>
                                                                : ''
                                                        }
                                                    </div>
                                                </div>
                                                :
                                                <div className="a_key_bottom a_key_bottom_3">
                                                    <div className="a_key_bottom_top result_statistics">
                                                        <div className="result_statistics_top">
                                                            <div style={{ color: "#333", fontWeight: 'bold' }}>
                                                                结果统计
                                                            </div>
                                                            {/* <LgButton type='info' shapeType='text'>查看工作量统计</LgButton> */}
                                                        </div>
                                                        <div className="result_statistics_div">
                                                            <div className="result_statistics_1 result_statistics_0">
                                                                <div>{weekDetail.typeOf === '1' ? '周' : '天'}数</div>
                                                                <div className="num_div"><span className="num_span">{setScheduleResult.statisticsResultVo.weekOrDayNum}</span>{weekDetail.typeOf === '1' ? '周' : '天'}</div>
                                                            </div>
                                                            <div className="result_statistics_2 result_statistics_0">
                                                                <div>每{weekDetail.typeOf === '1' ? '周' : '天'}参与人数</div>
                                                                <div className="num_div"><span className="num_span">{setScheduleResult.statisticsResultVo.partNum}</span>人</div>
                                                            </div>
                                                            <div className="result_statistics_3 result_statistics_0">
                                                                <div>参与总人数</div>
                                                                <div className="num_div"><span className="num_span">{setScheduleResult.statisticsResultVo.partTotalNum}</span>人</div>
                                                            </div>
                                                            <div className="result_statistics_4 result_statistics_0">
                                                                <div>人均值{isWeek}次数</div>
                                                                <div className="num_div"><span className="num_span">{setScheduleResult.statisticsResultVo.average}</span>次</div>
                                                            </div>
                                                            <div className="result_statistics_5 result_statistics_0">
                                                                <div>最大值{isWeek}次数</div>
                                                                <div className="num_div"><span className="num_span">{setScheduleResult.statisticsResultVo.maxPartTimes}</span>次</div>
                                                            </div>
                                                            <div className="result_statistics_6 result_statistics_0">
                                                                <div>最小值{isWeek}次数</div>
                                                                <div className="num_div"><span className="num_span">{setScheduleResult.statisticsResultVo.minPartTimes}</span>次</div>
                                                            </div>
                                                        </div>
                                                    </div>
                                                    <div className="a_key_bottom_bottom">
                                                        <div style={{ color: "#333", marginBottom: '10px', fontWeight: 'bold' }}>
                                                            排班结果
                                                        </div>
                                                        <LgTable
                                                            type={weekDetail.typeOf === '1' ? "aKey" : 'dayTable'}
                                                            AKeyWeekList={setResultList}
                                                            beLeader={weekDetail.beLeader === '1' ? true : false}
                                                            isSetFinish={true}
                                                            stepNum={'3'}
                                                            isEasy={isEasy}
                                                            dayPlayList={setResultList}
                                                            routine={routine}
                                                            explicit={explicit}
                                                            autoHeightMax={viewportHeight}
                                                        ></LgTable>
                                                    </div>
                                                </div>
                                    }

                                    <div className="a_key_btn">
                                        <LgButton
                                            className="cancel_btn"
                                            backgroundType="transparent"
                                            border
                                            type="info"
                                            onClick={() => this.lastStep()}
                                        >
                                            {
                                                step === 1 ? '取消' : '上一步'
                                            }
                                        </LgButton>
                                        <LgButton backgroundType="opacification" type="info" onClick={() => this.nextStep()}>
                                            {
                                                step === 3 ? '应用至值周安排' : '下一步'
                                            }
                                        </LgButton>
                                    </div>
                                </div>
                            ) : popLayerRecord || popLayerEditRecord ? (
                                <div className="record_table">
                                    <div className="record_table_input">
                                        <span style={{ color: "#999", marginRight: "8px" }}>
                                            记录表名称:
                                        </span>
                                        <LgInput
                                            className="record_table_name"
                                            maxLength={15}
                                            value={recordTableName}
                                            onChange={(e) => {
                                                this.setState({
                                                    recordTableName: e.currentTarget.value,
                                                });
                                            }}
                                        ></LgInput>
                                    </div>
                                    <div className="record_table_tip">
                                        <span style={{ color: "#999" }}>绑定值周值日安排表:</span>
                                        <span style={{ color: "#ff6600", marginLeft: "5px" }}>
                                            (绑定后，可智能关联填写人员，由值周人员填写对应日期的记录。可多选)
                                        </span>
                                    </div>
                                    <div className="record_table_table">
                                        <LgTable
                                            type={"recordTable"}
                                            recordList={WeekOrDayPlayList}
                                            checkRecord={this.checkRecord}
                                            popLayerEditRecord={popLayerEditRecord}
                                        ></LgTable>
                                    </div>
                                </div>
                            ) : setContentPop ? (
                                <div className="set_content_div">
                                    <div className="set_content_top">
                                        <div className="set_content_title">
                                            {!explicit ? '值周内容' : '值日内容'}：
                                        </div>
                                        <div className="set_content_btn">
                                            <LgButton
                                                backgroundType="opacification"
                                                showIcon
                                                icon={<LgButton.icon.Add></LgButton.icon.Add>}
                                                type="success"
                                                onClick={() => this.openPop("addContent1")}
                                            >
                                                添加{!explicit ? '值周' : '值日'}内容
                                            </LgButton>
                                        </div>
                                    </div>
                                    <div className="content_item_div">
                                        <LgTable
                                            type={'contentTable'}
                                            contentList={contentArr}
                                            isWeek={isWeek}
                                            noScroller={true}
                                            emptyText={`暂无值${isWeek}内容`}
                                            editContent={this.editContent}
                                            alertDelete={this.alertDelete}
                                        ></LgTable>
                                        {/* 2025-05-22 修改创建 */}
                                        {/* {(
                                            contentArr.map((item, index) => (
                                                <div key={index} className="content_item">
                                                    {item}
                                                    //如果需要添加删除功能，可以取消注释下一行
                                                    <i className="content_item_del" onClick={() => this.addContent('del', index)}></i>
                                                </div>
                                            ))
                                        )} */}
                                        {/* {
                                            isAddContent ?
                                                <div className="content_add_div">
                                                    <LgInput
                                                        className="content_input"
                                                        maxLength={15}
                                                        value={contentValue}
                                                        onChange={(e) => {
                                                            this.setState({
                                                                contentValue: e.currentTarget.value,
                                                            });
                                                        }}
                                                        input={{
                                                            autoFocus: true,
                                                        }}
                                                    ></LgInput>
                                                    <div className="is_ok" onClick={() => this.addContent('ok')}>√</div>
                                                    <div className="is_false" onClick={() => this.addContent('false')}>X</div>
                                                </div>
                                                :
                                                <div className="add_content" onClick={() => this.setState({ isAddContent: true })}>添加内容</div>
                                        } */}
                                    </div>
                                </div>
                            ) : workloadDetailPop ? (
                                <div className="set_content_div">
                                    <div className="set_content_top">
                                        <div className="set_content_title">
                                            <LgSelect
                                                SelectOption={this.SelectType}
                                                datalist={typeList}
                                                value={typeSelect}
                                                indexArr={[typeSelectIndex]}
                                                className="workload_select"
                                                placeholder={'请选择...'}
                                            ></LgSelect>
                                        </div>
                                        <div className="set_content_btn">
                                            <LgButton
                                                className="top_right_btn"
                                                backgroundType="transparent"
                                                border
                                                showIcon
                                                icon={<LgButton.icon.Share></LgButton.icon.Share>}
                                                type="info"
                                                onClick={() => this.userWorkloadStaticExport()}
                                            >
                                                导出
                                            </LgButton>
                                        </div>
                                    </div>
                                    <div className="content_item_div">
                                        <LgTable
                                            type={'workloadList'}
                                            detailList={workloadDetailList}
                                            noScroller={true}
                                            emptyText={`暂无值周值日内容`}
                                        ></LgTable>
                                        {/* 2025-05-22 修改创建 */}
                                    </div>
                                </div>
                            ) : (
                                ""
                            )}
                        </LgDrawer>
                        <LgPopLayer
                            className="reminder_time_pop"
                            title={
                                timeVisible
                                    ? "添加提醒时间"
                                    : exportedVisible
                                        ? "导出数据统计情况"
                                        : exportedRecordVisible ?
                                            '导出值周/值日记录'
                                            : addWeeksVisible
                                                ? (editWeeksVisible ? '编辑' : '添加') + (weekDetail.typeOf === '1' ? "周次" : '值日日期')
                                                : addContentVisible ? '添加记录事项' :
                                                    addContentPop ?
                                                        (editContentVisible ? '编辑' : '添加') + (weekDetail.typeOf === '1' ? "值周内容" : '值日内容')
                                                        : ''
                            }
                            isOpen={timeVisible || exportedVisible || exportedRecordVisible || addWeeksVisible || addContentVisible || addContentPop}
                            centered
                            width={
                                timeVisible ? "540px" : exportedVisible || exportedRecordVisible || addContentVisible ? "420px" : "540px"
                            }
                            height={
                                timeVisible ? "302px" : exportedVisible || exportedRecordVisible || addContentVisible ? "258px" : addContentPop ? '382px' : "302px"
                            }
                            onConfirm={this.okSelected}
                            onClose={this.cancelObjModal}
                            onIconClose={this.cancelObjModal}
                        >
                            {timeVisible ? (
                                <div className="reminder_time_div">
                                    <div className="reminder_time_top">
                                        <span className="reminder_time_span">
                                            <span style={{ color: "red" }}>*</span> 提醒时间:
                                        </span>
                                        <LgDatePicker type="C" start="06:30" step="00:15" end="23:30" maxTime="23:30"
                                            value={timeReminder} onChange={e => this.setState({ timeReminder: e })} />
                                    </div>
                                    <div className="reminder_time_middle">
                                        <span className="reminder_time_span">提醒事项:</span>
                                        <LgInput
                                            className="reminder_input"
                                            maxLength={15}
                                            value={remindValue}
                                            onChange={(e) => {
                                                this.setState({
                                                    remindValue: e.currentTarget.value,
                                                });
                                            }}></LgInput>
                                    </div>
                                    <div className="reminder_time_bottom">
                                        <span className="reminder_time_span">适用时间范围:</span>
                                        <div className="time_ranges_div">
                                            {timeRanges.map((item, index) => (
                                                <LgCheckbox
                                                    className={
                                                        index < 4 ? "check_item_top" : "check_item_bottom"
                                                    }
                                                    key={"checkbox" + index}
                                                    checked={item.checked}
                                                    onChange={this.onChange}
                                                    value={index}
                                                    label={item.label}
                                                />
                                            ))}
                                        </div>
                                    </div>
                                </div>
                            ) : exportedVisible || exportedRecordVisible ? (
                                <div className="exported_div">
                                    <div style={{ color: "#999999" }}>请选择导出的时间范围:</div>
                                    <div className="group_select">
                                        <LgRadio.Group
                                            value={radioValue}
                                            onChange={(nextValue, itm) =>
                                                this.setState(
                                                    {
                                                        radioValue: nextValue,
                                                    },
                                                    () => console.log(nextValue, "itm111", itm)
                                                )
                                            }
                                        >
                                            {timeList.map((item, index) => {
                                                return (
                                                    <LgRadio className="g006-form-1-item" value={index}>
                                                        {item.label}
                                                    </LgRadio>
                                                );
                                            })}
                                        </LgRadio.Group>
                                    </div>
                                    <div className="custom_time">
                                        {
                                            radioValue === 3 ?
                                                <LgDatePicker
                                                    format='yyyy/MM/dd'
                                                    type="B"
                                                    value={[exportStartTime, exportEndTime]}
                                                    disabledDate={time => time.getTime() < moment(statisticsStartDate).subtract(1, 'day').toDate() || time.getTime() > statisticsEndDate}
                                                    onChange={(e) => {
                                                        if (e instanceof Array) {
                                                            this.setState({
                                                                exportStartTime: e[0],
                                                                exportEndTime: e[1]
                                                            })
                                                            console.log("exportStartTime:", e[0], "exportEndTime:", e[1]);
                                                        }
                                                    }}></LgDatePicker>
                                                : ''
                                        }
                                    </div>
                                </div>
                            ) : addWeeksVisible ? (
                                <div className="add_week_div">
                                    <div className="week_info_div">
                                        <span className="add_week_span">
                                            <span style={{ color: "red" }}>*</span> 周次:
                                        </span>
                                        {/* <LgSelect
                                            SelectOption={this.SelectOptionA}
                                            datalist={cycleList}
                                            value={selectValue}
                                            indexArr={[]}
                                            className="week_select week_select1"
                                        ></LgSelect> */}
                                        <LgInputNumber value={weekNo} onChange={(value) => {
                                            this.setState({
                                                // weekInputNumber: value,
                                                weekNo: value,
                                            }, () => {
                                                if (value && value <= cycleList.length) {
                                                    this.debouncedGetWeekNum()
                                                }
                                            });
                                        }} size='small' max={cycleList.length} min={1}></LgInputNumber>
                                    </div>
                                    <div className="date_range">
                                        <span className="add_week_span">{weekDetail.typeOf === '1' ? '日期范围' : '值日日期'}:</span>
                                        {
                                            weekDetail.typeOf === '1' ?
                                                <LgDatePicker
                                                    format='yyyy/MM/dd'
                                                    type="B"
                                                    value={[start, end]}
                                                    // isDisabled={true}
                                                    disabledDate={time => time.getTime() < moment(termInfo?.termStartDate ? termInfo?.termStartDate : start).subtract(1, 'month').toDate() || time.getTime() > moment(termInfo?.termEndDate ? termInfo?.termEndDate : end).add(2, 'month').toDate()}
                                                    // disabledDate={time => time.getTime() < moment(start).subtract(1, 'day').toDate() || time.getTime() > end}
                                                    onChange={(e) => {
                                                        if (e instanceof Array) {
                                                            this.setState({
                                                                start: e[0],
                                                                end: e[1]
                                                            })
                                                            console.log("start:", e[0], "end:", e[1]);
                                                        }
                                                    }}
                                                />
                                                :
                                                <LgDatePicker
                                                    type="B"
                                                    format='yyyy/MM/dd'
                                                    value={[startDay, endDay]}
                                                    disabledDate={time => time.getTime() < moment(start).subtract(1, 'day').toDate() || time.getTime() > end}
                                                    onChange={(e) => {
                                                        if (e instanceof Array) {
                                                            this.setState({
                                                                startDay: e[0],
                                                                endDay: e[1]
                                                            })
                                                            console.log("start:", e[0], "end:", e[1]);
                                                        }
                                                    }}
                                                />
                                            // <LgDatePicker
                                            //     value={dayTimeAKey}
                                            //     disabledDate={time => time.getTime() < moment(start).subtract(1, 'day').toDate() || time.getTime() > end}
                                            //     onChange={(e) => {
                                            //         this.setState({ dayTimeAKey: e })
                                            //     }}
                                            // />
                                        }
                                    </div>
                                </div>
                            ) :
                                addContentVisible ?
                                    (
                                        <div className="reminder_time_div">
                                            <div className="reminder_time_middle">
                                                <span className="reminder_time_span">记录事项:</span>
                                                <LgInput
                                                    className="reminder_input"
                                                    maxLength={15}
                                                    value={addContentValue}
                                                    onChange={(e) => {
                                                        this.setState({
                                                            addContentValue: e.currentTarget.value,
                                                        });
                                                    }}></LgInput>
                                            </div>
                                        </div>
                                    )
                                    :
                                    addContentPop ?
                                        (
                                            <div className="add_content_div">
                                                <div className="content_div">
                                                    <div className="addContentPop_title"><span className="tip_xing">*</span>值{isWeek}内容:</div>
                                                    <div className="addContentPop_content">
                                                        <LgInput placeholder="请输入..."
                                                            maxLength={15}
                                                            value={contentValue} onChange={(e) => {
                                                                this.setState({
                                                                    contentValue: e.target.value
                                                                })
                                                            }} />
                                                    </div>
                                                </div>
                                                <div className="content_require">
                                                    <div className="require_title">
                                                        值{isWeek}要求:
                                                    </div>
                                                    <div className="require_div">
                                                        <LgTextarea
                                                            numberOfWords
                                                            className="textarea_require"
                                                            value={textareaRequireValue}
                                                            placeholder={`请输入...`}
                                                            textarea={{
                                                                onInput: this.handleInputChangeR,
                                                                maxLength: 200,
                                                            }}
                                                            currentTextQuantity={textareaRequireValue.length}
                                                        />
                                                    </div>
                                                </div>
                                            </div>
                                        )
                                        :
                                        (
                                            ""
                                        )}
                        </LgPopLayer>
                    </LgSideBarA>
                ) : (
                    <div className="teacher_terminal">
                        <LgBlockCard title=" " className="teacher_terminal_top">
                            <div className="terminal_top_div">
                                <div className="time_select">
                                    <div className="tips">
                                        <div className="my_week">我值周/值日</div>
                                        <div className="finish_record">记录已填写</div>
                                        <div className="no_finish_record">记录未填写</div>
                                    </div>
                                    {calendarData?.calendarVoList ? <UserCalendar getMyWeeklyDayDetailList={this.getMyWeeklyDayDetailList} calendarVoList={calendarData.calendarVoList}></UserCalendar> : <p>Loading...</p>}
                                </div>
                                <div className="height_line"></div>
                                <div className="teacher_week_info">
                                    {
                                        myWeeklyData.length > 0 ?
                                            <div className="teacher_week_top">
                                                我的值周值日安排({myWeeklyData.length})
                                            </div>
                                            : ''
                                    }
                                    <Scrollbars
                                        autoHeight
                                        autoHide
                                        autoHideTimeout={100}
                                        style={{
                                            height: "250px",
                                            minHeight: "250px",
                                        }}
                                        autoHeightMin={"250px"}
                                    >
                                        {
                                            myWeeklyData.length > 0 ?
                                                myWeeklyData.map((item, index) => {
                                                    let uniqueNames = [...new Set(item?.personNameList ? item.personNameList : [])];
                                                    let result = uniqueNames.map(name => {
                                                        if (name === userInfo.userName) {
                                                            return `${name}<span style="color: #ff6600;">(我)</span>`;
                                                        } else {
                                                            return name;
                                                        }
                                                    }).join('、');
                                                    return (
                                                        <div className="">
                                                            <div className="teacher_week_bottom">
                                                                <div className="week_time">
                                                                    <div className="week_time_span">
                                                                        <span style={{ fontWeight: 'bold' }}>{item.date}</span>
                                                                        <div className={"week_span " + (item.type === '2' ? 'day_span' : '')}>值{item.type === '2' ? '日' : '周'}</div>
                                                                    </div>
                                                                    {
                                                                        item?.recordId == null || item?.recordId == '' ?
                                                                            ''
                                                                            :
                                                                            <LgButton type="info" shapeType="text" onClick={() => this.openPop('teacherRecord', item)}>
                                                                                {item?.beRecordEdit === '1' ? '查看' : '填写'}记录
                                                                            </LgButton>
                                                                    }
                                                                </div>
                                                                <div className="week_person">
                                                                    <span className="teacher_span">人员:</span>
                                                                    <span dangerouslySetInnerHTML={{ __html: result }} ></span>
                                                                </div>
                                                                <div className="week_content">
                                                                    <span className="teacher_span">内容:</span>
                                                                    {item.content === '' || item.content === null ? <span style={{ color: '#999' }}>暂未安排内容</span> : item.content}
                                                                </div>
                                                                <div className="week_require">
                                                                    <span className="teacher_span">要求:</span>
                                                                    <div>
                                                                        {item.requirement === '' || item.requirement === null ? <span style={{ color: '#999' }}>暂未设置要求</span> : item.requirement}
                                                                    </div>
                                                                </div>
                                                            </div></div>
                                                    )
                                                })
                                                :
                                                <div className="no_data"><LgEmpty size="large">暂无数据</LgEmpty></div>
                                        }
                                    </Scrollbars>
                                </div>
                            </div>
                        </LgBlockCard>
                        <LgBlockCard
                            title=" "
                            className="teacher_terminal_bottom"
                        >
                            <div className="teacher_terminal_div">
                                <div className={"teacher_list_menu " + (dutyArr.length === 0 ? 'no_teacher_list' : '')}>
                                    {
                                        dutyArr.length === 0 ?
                                            <LgEmpty>暂无安排表</LgEmpty>
                                            :
                                            <Scrollbars
                                                autoHeight
                                                autoHide
                                                autoHideTimeout={100}
                                                style={{
                                                    height: "100%",
                                                    minHeight: "100%",
                                                }}
                                                autoHeightMin={"100%"}
                                            >
                                                <div className="teacher_list">
                                                    {
                                                        dutyArr.map((item, index) => {
                                                            return (
                                                                <div className="preview_weekly_list">
                                                                    <div
                                                                        className={
                                                                            (item.typeOf === '1' ? "week_template " : 'day_template ') +
                                                                            (templateType === index ? "active" : "")
                                                                        }
                                                                        onClick={() => this.editTemplate(index, item.arrangementId)}
                                                                    ></div>
                                                                    <div className="template_span">
                                                                        <div class="text_content" title={item?.arrangementName}>{item?.arrangementName}</div>
                                                                    </div>
                                                                </div>
                                                            )
                                                        })
                                                    }
                                                </div>
                                            </Scrollbars>
                                    }
                                </div>
                                {
                                    dutyArr.length === 0 ?
                                        <div className="no_teacher_list_table">
                                            <LgEmpty size="large">暂无数据</LgEmpty>
                                        </div>
                                        : <div className="teacher_list_table">
                                            <div className="table_name">{weekDetail?.arrangementName}</div>
                                            <Scrollbars
                                                autoHeight
                                                autoHide
                                                autoHideTimeout={100}
                                                autoHeightMax={'100%'}
                                            // style={{
                                            //     height: "calc(100% - 168px)",
                                            //     minHeight: "100px",
                                            //     // maxHeight: "calc(100% - 168px - 35px)",
                                            // }}
                                            // autoHeightMin={"100%"}
                                            >
                                                <LgTable
                                                    type={weekDetail?.typeOf === '1' ? "weekTable" : 'dayTable'}
                                                    weeklyPlayList={weekDetail?.weeklyPlayList}
                                                    dayPlayList={weekDetail?.dayPlayList}
                                                    recallPerson={this.recallPerson}
                                                    deletePerson={this.deletePerson}
                                                    editWeek={this.openDrawer}
                                                    publish={this.savePersonnel}
                                                    remindTeacherByPlay={this.remindTeacherByPlay}
                                                    isEasy={isEasy}
                                                    takeTurns={takeTurns}
                                                    routine={routine}
                                                    explicit={explicit}
                                                    noOperation={true}
                                                    noScroller={true}
                                                ></LgTable>
                                            </Scrollbars>
                                            <div className="teacher_remark">{textareaValue ? textareaValue : <span style={{ color: '#999' }}>暂无备注</span>}</div>
                                        </div>
                                }
                            </div>
                        </LgBlockCard>
                    </div>
                )}
                {teacherRecordPop ?
                    // console.log(timeRanges[2], 'timeRanges[Number(teacherTimeData.weekNo)]', weekDay, 'myWeeklyData', myWeeklyData)
                    <LgPopLayer
                        className="reminder_time_pop"
                        title={
                            `值${teacherTimeData.type === '1' ? '周' : '日'}记录`
                        }
                        subheading={moment(selectTime).format('YYYY/MM/DD') + '(' + weekDay + ')'}
                        isOpen={true}
                        centered
                        width={
                            '940px'
                        }
                        height={
                            '640px'
                        }
                        onConfirm={this.okSelected}
                        onClose={this.cancelObjModal}
                        onIconClose={this.cancelObjModal}
                        key={selectTime}
                        isShowBottom={false}
                    >
                        <div className="teacher_record">
                            <RecordTable headerName={weekSheetDetail2 && weekSheetDetail2.recordName} selectTime={selectTime} haveTop={true}
                                weekSheetDetail={weekSheetDetail2} recordInfoDetail={this.recordInfoDetail} haveSubmit={true}
                                closePop={() => this.cancelObjModal()} alertPersonEdit={this.alertPersonEdit} recordExport={() => this.recordExport(`值${teacherTimeData.type === '1' ? '周' : '日'}记录`)}
                            ></RecordTable>
                        </div>
                    </LgPopLayer>
                    : ''
                }
                {selectUserVisibleAKey && isManage !== '1' ? (
                    <SelectUserModal
                        className="select-user-item"
                        title={"选择领导"}
                        baseUrl={schoolSystemInfo.itemUrl} //http://192.168.122.124:22101/office-platform/
                        token={
                            sessionStorage.getItem("token") || getQueryVariable("lg_tk")
                        }
                        visible={selectUserVisibleAKey}
                        getSelectResult={this.getSelectList}
                        selectList={selectUserListAKey}
                        groupUserType={["0", "1", "11"]}
                        changeVisible={this.selectUserChange}
                        maxLength={40}
                        zIndex={1003}
                        schoolId={userInfo?.schoolId}
                    />
                ) : (
                    ""
                )}
                <ImportFile downloadTemplate={this.downloadTemplate} isOpen={importVisible} title={'导入安排表'} weekDetail={weekDetail} userInfo={userInfo} termInfo={termInfo}
                    closeImport={() => this.setState({ importVisible: false, })} getWeekDetail={this.getWeekDetail} ></ImportFile>
            </LgBlockCardBox>
        );
    }
}
export default DutyWeek;
